public void DeleteShoppingCartProduct_SuccessfulRequest() { //Arrange var controller = new ShoppingCartProductController(shoppingCartProductService.Object); shoppingCartProductRequest.ProductId = 1; shoppingCartProductResponse.Success = true; //We want a successful request. //Act var result = controller.DeleteShoppingCartProduct(shoppingCartProductRequest); //Assert shoppingCartProductService.Verify(ps => ps.DeleteShoppingCartProduct(shoppingCartProductRequest), Times.AtLeastOnce); //Verify method has been invoked. Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<string>)); //Response type is OK returning a string. }
public void AddToShoppingCart_FailedRequest() { //Arrange var controller = new ShoppingCartProductController(shoppingCartProductService.Object); shoppingCartProductRequest.ProductId = 1; shoppingCartProductRequest.Quantity = 3; shoppingCartProductResponse.Success = false; //We want a failed request. //Act var result = controller.AddToShoppingCart(shoppingCartProductRequest); //Assert shoppingCartProductService.Verify(ps => ps.AddShoppingCartProduct(shoppingCartProductRequest), Times.AtLeastOnce); //Verify method has been invoked. Assert.IsInstanceOfType(result, typeof(BadRequestResult)); //Response type is OK returning a string. }