public void ClearShoppingCart_SuccessfulRequest() { //Arrange var controller = new ShoppingCartProductController(shoppingCartProductService.Object); shoppingCartProductResponse.Success = true; //We want a successful request. //Act var result = controller.ClearShoppingCart(); //Assert shoppingCartProductService.Verify(ps => ps.ClearShoppingCartProducts(), Times.AtLeastOnce); //Verify method has been invoked. Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<string>)); //Response type is OK returning a string. }
public void ClearShoppingCart_FailedRequest() { //Arrange var controller = new ShoppingCartProductController(shoppingCartProductService.Object); shoppingCartProductResponse.Success = false; //We want a failed request. //Act var result = controller.ClearShoppingCart(); //Assert shoppingCartProductService.Verify(ps => ps.ClearShoppingCartProducts(), Times.AtLeastOnce); //Verify method has been invoked. Assert.IsInstanceOfType(result, typeof(BadRequestResult)); //Response type is OK returning a string. }