public void Created_ShouldReturnBadResult_WhenPostedInvalidModel() { var recipe = TestDataRepository.BuildCreateNewRecipeRequest(); recipe.Name = null; recipe.Instructions = null; var result = _recipesController.Create(recipe); var res = result.Result as BadRequestObjectResult; Assert.IsNotNull(res); }
public void Create_ShouldReturn201_WhenSucceeded() { var recipeRequest = TestDataRepository.BuildCreateNewRecipeRequest(); var result = _recipesController.Create(recipeRequest); var res = result.Result as CreatedAtActionResult; Assert.IsNotNull(res); var value = (CreateNewRecipeResponse)res.Value; Assert.IsNotNull(value); Assert.AreEqual(value.Recipe.Name, recipeRequest.Name); Assert.AreEqual(value.Recipe.Instructions, recipeRequest.Instructions); Assert.AreEqual(value.Recipe.Ingredients, recipeRequest.Ingredients); Assert.AreEqual(value.Recipe.URL, recipeRequest.URL); Assert.AreEqual(value.Recipe.Author, _user); }