public void FullyUpdateRecipe_InvalidRecipeId_ReturnsNotFound() { // Arrange int invalidRecipeId = 2; var recipeForUpdateDto = new RecipeForUpdateDto(); recipesServiceMock = new Mock <IRecipesService>(); recipesServiceMock .Setup(m => m.GetRecipe(invalidRecipeId)) .Returns(null as RecipeDto); recipesController = new RecipesController(recipesServiceMock.Object, mapper); // Act var result = recipesController.FullyUpdateRecipe(invalidRecipeId, recipeForUpdateDto); // Assert Assert.IsTrue(result.GetType() == typeof(NotFoundResult)); }
public void FullyUpdateRecipe_ValidRecipeIdAndValidData_ReturnsNoContent() { // Arrange int validRecipeId = 1; var recipeForUpdateDto = new RecipeForUpdateDto(); recipesServiceMock = new Mock <IRecipesService>(); recipesServiceMock .Setup(m => m.GetRecipe(validRecipeId)) .Returns(new RecipeDto()); recipesController = new RecipesController(recipesServiceMock.Object, mapper); // Act var result = recipesController.FullyUpdateRecipe(validRecipeId, recipeForUpdateDto); // Assert Assert.IsTrue(result.GetType() == typeof(NoContentResult)); }
public void FullyUpdateRecipe_ValidRecipeIdAndInvalidData_ReturnsBadRequest() { // Arrange int validRecipeId = 1; var recipeForUpdateDto = new RecipeForUpdateDto(); recipesServiceMock = new Mock <IRecipesService>(); recipesServiceMock .Setup(m => m.GetRecipe(validRecipeId)) .Returns(new RecipeDto()); recipesController = new RecipesController(recipesServiceMock.Object, mapper); recipesController.ModelState.AddModelError("Some Key", "Some Error Message"); // Act var result = recipesController.FullyUpdateRecipe(validRecipeId, recipeForUpdateDto); // Assert Assert.IsTrue(result.GetType() == typeof(BadRequestObjectResult)); }