[TestMethod] //NEED TO UPDATE THIS TO DELETE THE RECIPE AS WELL public void DELETE_GivenNutritionalInformation_DeleteTheNutritionalInformation() { //Arrange NutritionalInformation existingNutritionalInformation = new NutritionalInformation { Id = 5 }; //Act int result = repository.Delete<NutritionalInformation>(existingNutritionalInformation); repository.Commit(); //Assert Assert.IsNotNull(result); }
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 UPDATE_GivenExisting_NutritionalInformation_UpdateTheSaturates() { //Arrange NutritionalInformation existingNutritionalInformation = new NutritionalInformation { Id = 40, Calories = 650, Carbs = 20.00, CreateDateTime = DateTime.Now, CreatedByAuthor = "Terry McPherson", Fat = 3.00, Fibre = 20, ModifiedDateTime = DateTime.Now, Protein = 4, Salt = 6, Saturates = 45, Sugar = 7 }; //Act var result = repository.Update<NutritionalInformation>(existingNutritionalInformation); repository.Commit(); //Assert Assert.IsTrue(result.Saturates == existingNutritionalInformation.Saturates); }