Given the following test:
[Theory] [PropertyData("GetValidInputForDb")] public void GivenValidInputShouldOutputCorrectResult( string patientId , string patientFirstName ) { var fixture = new Fixture(); var sut = fixture.Create<HtmlOutputBuilder>(); sut.DoSomething();
I want to encapsulate the creation of a fixture in my class, something similar to:
[Theory] [CustomPropertyData("GetValidInputForDb")] public void GivenValidInputShouldOutputCorrectResult( string patientId , string patientFirstName , HtmlOutputBuilder sut ) { sut.DoSomething();
The problem is that I am using PropertyData , and the second is two input parameters. The fact that I'm trying to automatically create my device as a parameter throws an exception.
Here is the CustomPropertyData data:
public class CustomPropertyDataAttribute : CompositeDataAttribute { public CustomPropertyDataAttribute(string validInput) :base(new DataAttribute[] { new PropertyDataAttribute(validInput), new AutoDataAttribute(new Fixture() .Customize(new HtmlOutpuBuilderTestConvention() )), }) { } }
What are the solutions to this problem?
source share