Last active
December 16, 2015 12:28
-
-
Save moodmosaic/5434611 to your computer and use it in GitHub Desktop.
A discussion branch for a question on Stack Overflow about using AutoFixture declaratively.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/16145284/autofixture-how-to-express-the-following-code-declaratively/16145954?noredirect=1#16145284 | |
public class Tests | |
{ | |
[Theory] | |
[InlineAutoMockData(@"-o=C:\Temp\someFile -p=1")] | |
[InlineAutoMockData(@"-p=1 -o=C:\Temp\someFile")] | |
public void ParseMissingParameterShouldReturnCorrectResult( | |
string argsString, | |
SomeClass sut) | |
{ | |
} | |
[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) | |
{ | |
} | |
} | |
internal class InlineAutoMockDataAttribute : CompositeDataAttribute | |
{ | |
internal InlineAutoMockDataAttribute(params object[] values) | |
: base( | |
new InlineDataAttribute(values), | |
new AutoDataAttribute( | |
new Fixture().Customize( | |
new CompositeCustomization( | |
new AutoFakeItEasyCustomization())))) | |
{ | |
} | |
} | |
public class SomeClass : IQux | |
{ | |
private readonly IFoo foo; | |
public SomeClass(IFoo foo) | |
{ | |
this.foo = foo; | |
} | |
public IFoo Foo | |
{ | |
get { return this.foo; } | |
} | |
} | |
public interface IQux | |
{ | |
} | |
public interface IFoo | |
{ | |
} | |
public interface IBar | |
{ | |
} | |
public class Foo : IFoo | |
{ | |
public Foo(IBar bar) | |
{ | |
} | |
} | |
public class Bar : IBar | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment