public void DeleteRecipeTest() { // Arrange IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); database.AddRecipe(new RecipeDto() { Name = "Test", Amount = 0, PreparationDescription = "Preparation test", PreparationTime = TimeSpan.FromMinutes(30), SkillLevel = "Skill level test" }); // Act database.DeleteRecipe("Test"); // Assert List <RecipeSimplifiedDto> list = database.GetRecipeList(); foreach (RecipeSimplifiedDto r in list) { if (r.Name == "Test") { Assert.Fail(); } } }
public void AddShopListItem() { // Arrage IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); var item = new IngredientDto() { Amount = 3, IngredientName = "Test", Unit = "Test" }; // Act database.AddShopListItem("db1500c7-f616-45d3-8069-14a9f264f2fa", item); // Assert var list = database.GetShopList("db1500c7-f616-45d3-8069-14a9f264f2fa"); foreach (var i in list) { if (i.IngredientName == "Test") { database.DeleteRecipe("Test"); Assert.Pass(); } } Assert.Fail(); }
public void AddRecipeTest() { // Arrange IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); RecipeDto newRecipe = new RecipeDto() { Amount = 2, Name = "Test", PreparationDescription = "DescriptionTest", PreparationTime = new TimeSpan(0, 20, 0), SkillLevel = "Begginer", Ingredients = new List <IngredientDto>() { new IngredientDto() { Amount = 2, IngredientName = "IngredientTest", Unit = "UnitTest" }, new IngredientDto() { Amount = 2, IngredientName = "IngredientTest2", Unit = "UnitTest" } }, Picture = ImageConverter.ImagetoByteArray(@"C:\Users\Bartek\Downloads\zupa-pomidorowa.jpg") }; // Act database.AddRecipe(newRecipe); // Assert List <RecipeSimplifiedDto> list = database.GetRecipeList(); foreach (RecipeSimplifiedDto r in list) { if (r.Name == "Test") { // Cleanup and pass database.DeleteRecipe("Test"); Assert.Pass(); } } Debug.WriteLine("Check connection: " + factory.GetConnectionString()); Assert.Fail(); }