public void When_Clear_IsCalled_Should_RespondWith_NoContent()
        {
            Cart cart = new Cart();

            using (var controller = new CartController(new FakeProductRepository(), cart))
            {
                cart.AddItem(new Product()
                {
                    ProductId = 1, Name = "Mouse"
                }, 1);
                cart.AddItem(new Product()
                {
                    ProductId = 2, Name = "Keyboard"
                }, 1);

                // Act
                IActionResult actionResult    = controller.Clear();
                var           noContentResult = actionResult as NoContentResult;

                // Assert
                Assert.NotNull(noContentResult);
                Assert.Equal(204, noContentResult.StatusCode);
                Assert.Empty(cart.Lines);
            }
        }
Exemplo n.º 2
0
        public void Clear()
        {
            //arrange
            CartController cartController = new CartController(Mocks.GetProductRepository());

            //act
            IActionResult result = cartController.Clear(Mocks.GetCart());

            Assert.AreEqual(typeof(RedirectToActionResult), result.GetType());
        }