コード例 #1
0
ファイル: MyClassTest.cs プロジェクト: RyanLiu99/AutoFixture
        public void NumberSumIsCorrect_DerivedFixture()
        {
            // Fixture setup
            MyClassFixture fixture = new MyClassFixture();
            fixture.AddManyTo(fixture.Things);

            int expectedSum = 
                fixture.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
        }
コード例 #2
0
        public void NumberSumIsCorrect_DerivedFixture()
        {
            // Fixture setup
            MyClassFixture fixture = new MyClassFixture();

            fixture.AddManyTo(fixture.Things);

            int expectedSum =
                fixture.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
        }