コード例 #1
0
        public void Test_Busket_Return_Right_Object()
        {
            //arrange
            OrderController controller = new OrderController(_orderService.Object);
            OrderViewModel model = new OrderViewModel()
            {
                CustomerId = 1,
                OrderDate = DateTime.UtcNow
            };

            //act
            var result = controller.Busket(model) as ViewResult;

            //assert
            Assert.AreEqual(1, (result.Model as OrderViewModel).CustomerId);
        }
コード例 #2
0
        public void Test_Order_Return_Right_Model_In_View()
        {
            //arrange
            OrderController controller = new OrderController(_orderService.Object);
            OrderViewModel model = new OrderViewModel()
            {
                CustomerId = 1,
                OrderDate = DateTime.UtcNow
            };

            //act
            ViewResult result = controller.Order(model);

            //assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, (result.Model as OrderViewModel).CustomerId);
        }
コード例 #3
0
        public void Test_Buy_Call_Pay()
        {
            //arrange
            OrderController controller = new OrderController(_orderService.Object);
            OrderViewModel model = new OrderViewModel()
            {
                CustomerId = 1,
                OrderDate = DateTime.UtcNow
            };
            Mock<IPayMethod> payMethod = new Mock<IPayMethod>();

            //act
            controller.Buy(model, payMethod.Object);

            //assert
            payMethod.Verify( p => p.Pay(It.Is<OrderViewModel>( i => i.CustomerId == model.CustomerId )) );
        }