public void TestDeleteAll_Valid() { var mockRepo = new Mock <IShoppingCartRepository>(); mockRepo.Setup(r => r.DeleteAll()).Returns(true); var controller = new ShoppingCartsController(mockRepo.Object, mockCache); var result = controller.Delete(); var okResult = Assert.IsType <OkResult>(result); }
public void TestDelete_Invalid() { var cart = new ShoppingCart() { ID = -1, ProductId = 1, Quantity = 1, UserId = 1 }; var mockRepo = new Mock <IShoppingCartRepository>(); mockRepo.Setup(r => r.Delete(cart)).Returns(false); mockRepo.Setup(r => r.Get(cart.ID)).Returns <ShoppingCart>(null); var controller = new ShoppingCartsController(mockRepo.Object, mockCache); var result = controller.Delete(cart.ID); var okResult = Assert.IsType <NotFoundResult>(result); }