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); } }
public void Clear() { //arrange CartController cartController = new CartController(Mocks.GetProductRepository()); //act IActionResult result = cartController.Clear(Mocks.GetCart()); Assert.AreEqual(typeof(RedirectToActionResult), result.GetType()); }