Пример #1
0
 internal MyClassFixture()
 {
     this.Things = new List<Thing>();
     this.Register<IMyInterface>(() =>
         {
             var fake = new FakeMyInterface();
             this.Things.ToList().ForEach(t =>
                 fake.AddThing(t));
             return fake;
         });
 }
Пример #2
0
 internal MyClassFixture()
 {
     this.Things = new List <Thing>();
     this.Register <IMyInterface>(() =>
     {
         var fake = new FakeMyInterface();
         this.Things.ToList().ForEach(t =>
                                      fake.AddThing(t));
         return(fake);
     });
 }
Пример #3
0
        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
        }
Пример #4
0
        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
        }