public void Submitting_Empty_Shipping_Details_Displays_Default_View_With_Error()
        {
            CartController controller = new CartController(null,null);
            controller.ControllerContext = new ControllerContext();
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);

            var result = controller.CheckOut(cart, new FormCollection {
                {"Name", "" }
            });
            Assert.IsEmpty(result.ViewName);
            Assert.IsFalse(result.ViewData.ModelState.IsValid);
        }
        public void Valie_Order_Goes_To_Submitter_And_Displays_Completed_View()
        {
            var mockSubmitter = new Moq.Mock<IOrderSubmitter>();
            CartController controller = new CartController(null, mockSubmitter.Object);
            controller.ControllerContext = new ControllerContext();
            Cart cart = new Cart();
            cart.AddItem(new Product(), 1);
            var formData = new FormCollection
            {
                {"Name","Steve" }, {"Line1","123 My Street" },
                {"Line2", "MyArea" }, {"Line3","" },
                {"City","MyCity" }, {"State","Some State" },
                {"Zip","123ABCDEF" }, {"Country","Far far away" },
                {"GiftWrap",bool.TrueString }
            };

            var result = controller.CheckOut(cart, formData);

            Assert.AreEqual("Completed", result.ViewName);
            mockSubmitter.Verify(x => x.SubmitOrder(cart));
            Assert.AreEqual(0, cart.Lines.Count);
        }
        public void Submitting_Order_With_No_Lines_Displays_View_With_Error()
        {
            CartController controller = new CartController(null,null);
            Cart cart = new Cart();

            var result = controller.CheckOut(cart, new FormCollection());

            Assert.IsEmpty(result.ViewName);
            Assert.IsFalse(result.ViewData.ModelState.IsValid);
        }