Last active
August 29, 2015 14:21
-
-
Save blairconrad/7b3312e2996b72d7e5cc to your computer and use it in GitHub Desktop.
FakeItEasy FixtureInitialization sample
This file contains hidden or 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
public class FixtureInitializationSample | |
{ | |
public interface IFoo | |
{ | |
string Boo(); | |
} | |
public class SystemUnderTest | |
{ | |
private readonly IFoo foo; | |
public SystemUnderTest(IFoo foo) | |
{ | |
this.foo = foo; | |
} | |
public string Double() | |
{ | |
return foo.Boo() + foo.Boo(); | |
} | |
} | |
[UnderTest] | |
private SystemUnderTest sut; | |
[Fake] | |
private IFoo fakeFoo; | |
[Test] | |
public void Double_should_double_the_boo_of_foo() | |
{ | |
Fake.InitializeFixture(this); // could be in setup | |
A.CallTo(() => fakeFoo.Boo()).Returns("Boo who?"); | |
Assert.That(sut.Double(), Is.EqualTo("Boo who?Boo who?")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment