You can declare the SUT (which is the SomeClass
type) as a parameter on the test method:
[Theory]
[InlineAutoMockData(@"-o=C:\Temp\someFile -p=1")]
[InlineAutoMockData(@"-p=1 -o=C:\Temp\someFile")]
public void ParseMissingParameterShouldReturnCorrectResult(
string argsString,
SomeClass sut)
{
}
An easy way to create the [InlineAutoMockData]
attribute is:
internal class InlineAutoMockDataAttribute : CompositeDataAttribute
{
internal InlineAutoMockDataAttribute (params object[] values)
: base(
new InlineDataAttribute(values),
new AutoDataAttribute(
new Fixture().Customize(
new CompositeCustomization(
new AutoMoqCustomization()))))
{
}
}
Note:
If you also need to setup expectations on the IFoo
or IBar
mocked instances you can freeze them so that the same Frozen
instances are passed in the SomeClass
instance:
[Theory]
[InlineAutoMockData(@"-o=C:\Temp\someFile -p=1")]
[InlineAutoMockData(@"-p=1 -o=C:\Temp\someFile")]
public void ParseMissingParameterShouldReturnCorrectResult2(
string argsString,
[Frozen]Mock<IFoo> mock,
[Frozen]Mock<IBar> stub,
SomeClass sut)
{
}