public void Valid_Order_Goes_To_Submitter_And_Displays_Completed_View()
        {
            // Arrange
            var mockSubmitter = new Moq.Mock<IOrderSubmitter>();
            CartController controller = new CartController(null, mockSubmitter.Object);
            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 }
            };

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

            // Assert
            Assert.AreEqual("Completed", result.ViewName);
            mockSubmitter.Verify(x => x.SubmitOrder(cart));
            Assert.AreEqual(0, cart.Lines.Count);
        }
 public void Submitting_Empty_Shipping_Details_Displays_Default_View_With_Error()
 {
     // Arrange
     CartController controller = new CartController(null, null);
     Cart cart = new Cart();
     cart.AddItem(new Product(), 1);
     // Act
     var result = controller.CheckOut(cart, new FormCollection {
     { "Name", "" }
     });
     // Assert
     Assert.IsEmpty(result.ViewName);
     Assert.IsFalse(result.ViewData.ModelState.IsValid);
 }
 public void Submitting_Order_With_No_Lines_Displays_Default_View_With_Error()
 {
     // Arrange
     CartController controller = new CartController(null, null);
     Cart cart = new Cart();
     // Act
     var result = controller.CheckOut(cart, new FormCollection());
     // Assert
     Assert.IsEmpty(result.ViewName);
     Assert.IsFalse(result.ViewData.ModelState.IsValid);
 }