public void ADD_GivenARecipe_WhenTheRecipeIsAdded_BeSureThatItReturnsAnId() { //Arrange //Need to key in both Nutritional Information AND Recipe when adding now //Due to 1 to 1 constraint.....but recipe Id is comming back blank //May need to build this into business rules. Recipe newRecipe = new Recipe { CookingTime = new TimeSpan(3, 00, 00), CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry Mcpherson", Difficulty = Recipes.DataAccess.Enums.Difficulty.Difficult, Method = "1. Whip the cream", ModifiedDateTime = DateTime.Now, PreparationTime = new TimeSpan(2, 00, 00), Serves = 6, Title = "Shepherd Pie", RecipeType = Recipes.DataAccess.Enums.RecipeType.Main }; NutritionalInformation newNutritionalInfo = new NutritionalInformation { CreateDateTime = DateTime.Now, ModifiedDateTime = DateTime.Now, Calories = 3, Carbs = 6, CreatedByAuthor = "Sally Harding", Fat = 6, Fibre = 6, Protein = 11, Salt = 8, }; //Act newRecipe.NutritionalInformation = newNutritionalInfo; var result = repository.Add<Recipe>(newRecipe); repository.Commit(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Recipe)); Assert.IsTrue(result.Id > 0); Assert.IsTrue(result.Title != null); }
[TestMethod] //**PROBLEM RECIPE ID IS NOT BEING POPULATED!! public void ADD_GivenNutritionalInformation_CheckThatTheNewNutritionalInfoIsAdded() { //Arrange NutritionalInformation newNutritionalInformation = new NutritionalInformation { Calories = 650, Carbs = 20.00, CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry McPherson", Fat = 3.00, Fibre = 20, ModifiedDateTime = DateTime.Now, Protein = 4, Salt = 6, Saturates = 12, Sugar = 7 }; Recipe newRecipe = new Recipe { CookingTime = new TimeSpan(3, 00, 00), CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry Mcpherson", Difficulty = Recipes.DataAccess.Enums.Difficulty.Difficult, Method = "1. Whip the cream", ModifiedDateTime = DateTime.Now, PreparationTime = new TimeSpan(2, 00, 00), Serves = 6, Title = "Chicken Pie", RecipeType = Recipes.DataAccess.Enums.RecipeType.Main }; //Act newNutritionalInformation.Recipe = newRecipe; var result = repository.Add<NutritionalInformation>(newNutritionalInformation); repository.Commit(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NutritionalInformation)); Assert.IsTrue(result.Id > 0); }
public void DELETE_GivenARecipeId_DeleteTheRecipe() { //Arrange Recipe existingRecipe = new Recipe { Id = 17, CookingTime = new TimeSpan(3, 00, 00), CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry Mcpherson", Difficulty = Recipes.DataAccess.Enums.Difficulty.Difficult, Method = "2. Whip the cream", ModifiedDateTime = DateTime.Now, PreparationTime = new TimeSpan(2, 00, 00), Serves = 6, Title = "NOTShepherd Pie", RecipeType = Recipes.DataAccess.Enums.RecipeType.Main }; //Act int deleted = repository.Delete(existingRecipe); repository.Commit(); //Assert Assert.IsInstanceOfType(deleted, typeof(int)); }
public void UPDATE_GivenARecipe_WhenUpdateIsCalled_UpdateTheDescription() { //Arrange Recipe existingRecipe = new Recipe { Id = 12, CookingTime = new TimeSpan(3, 00, 00), CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry Mcpherson", Difficulty = Recipes.DataAccess.Enums.Difficulty.Difficult, Method = "2. Whip the cream", ModifiedDateTime = DateTime.Now, PreparationTime = new TimeSpan(2, 00, 00), Serves = 6, Title = "NOTShepherd Pie", RecipeType = Recipes.DataAccess.Enums.RecipeType.Main }; //Act var result = repository.Update<Recipe>(existingRecipe).Id; repository.Commit(); //Assert Assert.IsNotNull(result); }