Skip to content

Instantly share code, notes, and snippets.

@blairconrad
Last active August 29, 2015 14:21
Show Gist options
  • Save blairconrad/7b3312e2996b72d7e5cc to your computer and use it in GitHub Desktop.
Save blairconrad/7b3312e2996b72d7e5cc to your computer and use it in GitHub Desktop.
FakeItEasy FixtureInitialization sample
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