當前位置: 首頁>>代碼示例>>C#>>正文


C# CartController.Checkout方法代碼示例

本文整理匯總了C#中SportsStore.WebUI.Controllers.CartController.Checkout方法的典型用法代碼示例。如果您正苦於以下問題:C# CartController.Checkout方法的具體用法?C# CartController.Checkout怎麽用?C# CartController.Checkout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SportsStore.WebUI.Controllers.CartController的用法示例。


在下文中一共展示了CartController.Checkout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            // Arrange - create a mock order processor
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();

            // Arrange - create an empty cart
            Cart cart = new Cart();

            // Arrange - create shipping details
            ShippingDetails shippingDetails = new ShippingDetails();

            // Arrange - create an instance of the controller
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert - check that the order hasn't been passed on to the processor
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()),
            Times.Never());

            // Assert - check that the method is returning the default view
            Assert.AreEqual("", result.ViewName);

            // Assert - check that I am passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:JakeRyu,項目名稱:SportsStore,代碼行數:27,代碼來源:CartTests.cs

示例2: Cannot_Checkout_Invalid_ShippingDetails

        public void Cannot_Checkout_Invalid_ShippingDetails()
        {
            // Arrange - create a mock order processor
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();

            // Arrange - create a cart with an item
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);

            // Arrange - create an instance of the controller
            CartController target = new CartController(null, mock.Object);

            // Arrange - add an error to the model
            target.ModelState.AddModelError("error", "error");

            // Act - try to checkout
            ViewResult result = target.Checkout(cart, new ShippingDetails());

            // Assert - check that the order hasn't been passed on to the processor
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()),
                Times.Never());
            // Assert - check that the method is returning the default view
            Assert.AreEqual("", result.ViewName);
            // Assert - check that I am passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:devscott,項目名稱:SportsStore,代碼行數:26,代碼來源:CartControllerTests.cs

示例3: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            // Arragne - Mock 주문 처리기 생성
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            // Arrange - 빈 Cart 개체 생성
            Cart cart = new Cart();

            // Arragne - 배송 정보 생성
            ShippingDetails shippingDetails = new ShippingDetails();

            // Arrange - 컨트롤러의 인스턴스 생성
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert - 주문이 주문 처리기에 전달되지 않은 것을 확인한다.
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()),
                Times.Never());
            // Assert - 메서드가 기본 뷰를 반환했는지 확인한다.
            Assert.AreEqual("", result.ViewName);

            // Assert - 유효하지 않은 모델을 뷰에 전달하는지 확인한다
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:EthanK28,項目名稱:pro-asp-mvc5,代碼行數:25,代碼來源:CartTests.cs

示例4: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            ShippingDetails shippingDetails = new ShippingDetails();
            CartController target = new CartController(null, mock.Object);

            ViewResult result = target.Checkout(cart, shippingDetails);

            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never());
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:pavlove,項目名稱:SportsStore,代碼行數:13,代碼來源:CartTests.cs

示例5: Can_Checkout_And_Submit_Order

        public void Can_Checkout_And_Submit_Order()
        {
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);
            CartController target = new CartController(null,mock.Object);

            ViewResult result = target.Checkout(cart, new ShippingDetails());

            mock.Verify(m=>m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Once());
            Assert.AreEqual("Completed", result.ViewName);
            Assert.AreEqual(true, result.ViewData.ModelState.IsValid);
        }
開發者ID:vikranthc,項目名稱:SportsStore,代碼行數:13,代碼來源:UnitTest1.cs

示例6: Cannot_Checkout_Invalid_ShippingDetails

        public void Cannot_Checkout_Invalid_ShippingDetails()
        {
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);
            CartController target = new CartController(null, mock.Object);
            target.ModelState.AddModelError("error", "error");

            ViewResult result = target.Checkout(cart, new ShippingDetails());

            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never());
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:gkudel,項目名稱:SportsStore,代碼行數:14,代碼來源:CartTest.cs

示例7: Cannot_Checkout_empty_cart

        public void Cannot_Checkout_empty_cart()
        {
            var mock = new Mock<IOrderProcessor>();
            var cart = new Cart();
            var shipping = new ShippingDetails();

            var controller = new CartController(null, mock.Object);

            var result = controller.Checkout(cart, shipping);

            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never);

            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:vcaraulean,項目名稱:Pro-ASP-NET-MVC-SportsStore,代碼行數:15,代碼來源:CartControllerTests.cs

示例8: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            Mock<IOrderProcessor> mockProc = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            ShippingDetails shippingDetails = new ShippingDetails();
            CartController target = new CartController(null, mockProc.Object);

            ViewResult result = target.Checkout(cart, shippingDetails);

            //Assert - check that the order hasn't been passed on to the processor, means that ProcessorOrder was never invoked
            mockProc.Verify(mock=> mock.ProcessorOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never);
            //Assert - check that the method is returning the default view
            Assert.AreEqual("", result.ViewName);
            //Assert- check that i am passing an invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:Gluba,項目名稱:SportsStore,代碼行數:16,代碼來源:CartTests.cs

示例9: Cannot_Checkout_And_Submit_Order

        public void Cannot_Checkout_And_Submit_Order()
        {
            Mock<IOrderProcessor> mockProc = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);

            CartController target = new CartController(null, mockProc.Object);
            ViewResult result = target.Checkout(cart, new ShippingDetails());

            //Assert - check that the order hasn't been passed on to the processor, means that ProcessorOrder was never invoked
            mockProc.Verify(mock=> mock.ProcessorOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Once);
            //Assert - check that the method is returning the default view
            Assert.AreEqual("Completed", result.ViewName);
            //Assert- check that i am passing an invalid model to the view
            Assert.AreEqual(true, result.ViewData.ModelState.IsValid);
        }
開發者ID:Gluba,項目名稱:SportsStore,代碼行數:16,代碼來源:CartTests.cs

示例10: Cannot_Chechout_Empty_Cart

        public void Cannot_Chechout_Empty_Cart()
        {
            // Arrange
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            ShippingDetails shippingDetails = new ShippingDetails();
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never()); //Verify that order is never sent to the processor
            Assert.AreEqual("", result.ViewName); // Check that method is returning same view
            Assert.IsFalse(result.ViewData.ModelState.IsValid);
        }
開發者ID:djandreski,項目名稱:SportsStore,代碼行數:16,代碼來源:CartTest.cs

示例11: Can_checkout_and_submit_order

        public void Can_checkout_and_submit_order()
        {
            var mock = new Mock<IOrderProcessor>();
            var cart = new Cart();
            cart.AddItem(new Product(), 1);
            var shipping = new ShippingDetails();

            var controller = new CartController(null, mock.Object);

            var result = controller.Checkout(cart, shipping);

            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Once);

            Assert.AreEqual("Completed", result.ViewName);
            Assert.AreEqual(true, result.ViewData.ModelState.IsValid);
        }
開發者ID:vcaraulean,項目名稱:Pro-ASP-NET-MVC-SportsStore,代碼行數:16,代碼來源:CartControllerTests.cs

示例12: Cannot_Checkout_EmptyCart

        public void Cannot_Checkout_EmptyCart()
        {
            //arrange - Create a mock order process

            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();

            ShippingDetails shippingDetails = new ShippingDetails();
            CartController controller = new CartController(null, mock.Object );

            ViewResult result = controller.Checkout(cart, shippingDetails);

            mock.Verify(m=>m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.AtLeastOnce());
            Assert.AreEqual("", result.ViewName);
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:Hotjava,項目名稱:Practise_Code,代碼行數:16,代碼來源:CartTest.cs

示例13: Cannot_Checkout_Empty_Cart

        public void Cannot_Checkout_Empty_Cart()
        {
            // Arrange
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            Cart cart = new Cart();
            ShippingDetails shippingDetails = new ShippingDetails();
            CartController target = new CartController(null, mock.Object);

            // Act
            ViewResult result = target.Checkout(cart, shippingDetails);

            // Assert
            // check that the order hasn't been passed on to the processor
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), Times.Never());
            Assert.AreEqual(string.Empty, result.ViewName);
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:tenzinkabsang,項目名稱:SportsStoreKnockoutified,代碼行數:17,代碼來源:UnitTest1.cs

示例14: Can_Checkout_And_Submit_Order

        public void Can_Checkout_And_Submit_Order() {
            // Arrange - create a mock order processor
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            // Arrange - create a cart with an item
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);
            // Arrange - create an instance of the controller
            CartController target = new CartController(null, mock.Object);

            // Act - try to checkout
            ViewResult result = target.Checkout(cart, new ShippingDetails());

            // Assert - check that the order has been passed on to the processor
            mock.Verify(m => m.ProcessOrder(It.IsAny<Cart>(), It.IsAny<ShippingDetails>()), 
                Times.Once());
            // Assert - check that the method is returning the Completed view
            Assert.AreEqual("Completed", result.ViewName);
            // Assert - check that we are passing an valid model to the view
            Assert.AreEqual(true, result.ViewData.ModelState.IsValid);
        }
開發者ID:evkap,項目名稱:AspNetMvcTestApp,代碼行數:20,代碼來源:CartControllerTest.cs

示例15: Cannot_Checkout_Imvalid_ShippingDetails

        public void Cannot_Checkout_Imvalid_ShippingDetails()
        {
            // Arrange - Create a mock order processor
            Mock<IOrderProcessor> mock = new Mock<IOrderProcessor>();
            // Arrange - create a cart with an item
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);

            // Arrange - create an instance of the controller
            CartController target = new CartController(null, mock.Object);
            // Arrage - add an erro to the model
            target.ModelState.AddModelError("error", "error");

            // Act - try to checkout
            ViewResult result = target.Checkout(cart, new ShippingDetails());

            // Assert - check that the model is returning the default view
            Assert.AreEqual("", result.ViewName);
            // Assert - check that we are passing an  invalid model to the view
            Assert.AreEqual(false, result.ViewData.ModelState.IsValid);
        }
開發者ID:tonousa,項目名稱:SportsStore,代碼行數:21,代碼來源:CartTests.cs


注:本文中的SportsStore.WebUI.Controllers.CartController.Checkout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。