internal MyClassFixture() { this.Things = new List<Thing>(); this.Register<IMyInterface>(() => { var fake = new FakeMyInterface(); this.Things.ToList().ForEach(t => fake.AddThing(t)); return fake; }); }
internal MyClassFixture() { this.Things = new List <Thing>(); this.Register <IMyInterface>(() => { var fake = new FakeMyInterface(); this.Things.ToList().ForEach(t => fake.AddThing(t)); return(fake); }); }
public void NumberSumIsCorrect_AutoFixture() { // Fixture setup Fixture fixture = new Fixture(); IMyInterface fake = new FakeMyInterface(); fixture.Register<IMyInterface>(() => fake); var things = fixture.CreateMany<Thing>().ToList(); things.ForEach(t => fake.AddThing(t)); int expectedSum = things.Select(t => t.Number).Sum(); MyClass sut = fixture.Create<MyClass>(); // Exercise system int result = sut.CalculateSumOfThings(); // Verify outcome Assert.Equal<int>(expectedSum, result); // Teardown }
public void NumberSumIsCorrect_AutoFixture() { // Fixture setup Fixture fixture = new Fixture(); IMyInterface fake = new FakeMyInterface(); fixture.Register <IMyInterface>(() => fake); var things = fixture.CreateMany <Thing>().ToList(); things.ForEach(t => fake.AddThing(t)); int expectedSum = things.Select(t => t.Number).Sum(); MyClass sut = fixture.CreateAnonymous <MyClass>(); // Exercise system int result = sut.CalculateSumOfThings(); // Verify outcome Assert.Equal <int>(expectedSum, result); // Teardown }