예제 #1
0
파일: Scenario.cs 프로젝트: aly-ba/methodes
        public void UseVistorToCalculateSimpleTotal()
        {
            // Fixture setup
            var basket = new Basket(
                new BasketItem("Chocolate", 50, 2),
                new BasketItem("Rice", 30, 1),
                new BasketItem("Wine", 110, 1));
            // Exercise system
            var actual = basket.Accept(new BasketTotalVisitor());
            // Verify outcome
            var btv = Assert.IsAssignableFrom <BasketTotalVisitor>(actual);

            Assert.Equal(240, btv.Total);
            // Teardown
        }
예제 #2
0
        public void AcceptReturnsCorrectResult(
            [Frozen] IBasketVisitor v1
            , [Frozen] IBasketVisitor v2
            , [Frozen] IBasketVisitor v3
            , [Frozen] IBasketElement e1Stub
            , [Frozen] IBasketElement e2Stub
            , Basket sut
            )
        {
            // Fixture setup
            A.CallTo(() => e1Stub.Accept(v1)).Returns(v2);
            A.CallTo(() => e2Stub.Accept(v2)).Returns(v3);

            // Exercise system
            var actual = sut.Accept(v1);

            // Verify outcome
            Assert.Same(v3, actual);
            // Fixture teardown
        }
예제 #3
0
        public void AcceptReturnsCorrectResult()
        {
            // Fixture setup
            var r = new MockRepository(MockBehavior.Default)
            {
                DefaultValue = DefaultValue.Mock
            };
            var v1     = r.Create <IBasketVisitor>().Object;
            var v2     = r.Create <IBasketVisitor>().Object;
            var v3     = r.Create <IBasketVisitor>().Object;
            var e1Stub = r.Create <IBasketElement>();
            var e2Stub = r.Create <IBasketElement>();

            e1Stub.Setup(e => e.Accept(v1)).Returns(v2);
            e2Stub.Setup(e => e.Accept(v2)).Returns(v3);

            var sut = new Basket(e1Stub.Object, e2Stub.Object);
            // Exercise system
            var actual = sut.Accept(v1);

            // Verify outcome
            Assert.Same(v3, actual);
            // Teardown
        }