public void TwoMatchingRecipes() { var ctx = GetContextWithData(); ctx.FridgeProducts.Add(fridge1Product1); ctx.RecipeProducts.Add(recipe1Product1); ctx.RecipeProducts.Add(recipe2Product1); ctx.RecipeProducts.Add(recipe3Product6); ctx.Recipes.Add(recipe1); ctx.Recipes.Add(recipe2); ctx.Recipes.Add(recipe3); ctx.SaveChanges(); ResultDataService resultDataService = new ResultDataService(ctx, fridgeRepositoryMock.Object); List <Recipe> expectedList = new List <Recipe> { recipe1, recipe2 }; SortByRecipeId(expectedList); List <Recipe> actualList = resultDataService.GetAllMatchingPublicPlusUserRecipes(firstUserGuid).ToList(); SortByRecipeId(actualList); actualList.ShouldBeEquivalentTo(expectedList); }
private void NoMatchesWithSomeFridgeProducts() { setUpMocks(); //set up collections fridge.FridgeProducts.Add(fridgeProduct1); fridge.FridgeProducts.Add(fridgeProduct2); fridge.FridgeProducts.Add(fridgeProduct3); fridgeProductForDbSetList = new List <FridgeProduct> { fridgeProduct1, fridgeProduct2, fridgeProduct3 }; recipe1.RecipeProducts.Add(recipe1Product4); recipe2.RecipeProducts.Add(recipe2Product4); recipe3.RecipeProducts.Add(recipe3Product4); recipe4.RecipeProducts.Add(recipe4Product4); recipeForDbSetList = new List <Recipe> { recipe1, recipe2, recipe3, recipe4 }; recipeProductForDbSetList = new List <RecipeProduct> { recipe1Product4, recipe2Product4, recipe3Product4, recipe4Product4 }; //fillDbSets setUpDbSets(); List <Recipe> expectedList = new List <Recipe> { }; ResultDataService resultDataService = new ResultDataService(dbContextCreator); List <Recipe> resultList = resultDataService.GetRecipes().ToList(); Assert.Equal(expectedList, resultList); }
public void FridgeHasAllProductsSoAllRecipesAreAvailable() { setUpMocks(); //set up collections fridge.FridgeProducts.Add(fridgeProduct1); fridge.FridgeProducts.Add(fridgeProduct2); fridge.FridgeProducts.Add(fridgeProduct3); fridge.FridgeProducts.Add(fridgeProduct4); recipe1.RecipeProducts.Add(recipe1Product1); recipe1.RecipeProducts.Add(recipe1Product2); recipe1.RecipeProducts.Add(recipe1Product3); recipe1.RecipeProducts.Add(recipe1Product4); recipeForDbSetList.Add(recipe1); recipeForDbSetList.Add(recipe2); recipe3.RecipeProducts.Add(recipe3Product1); recipeForDbSetList.Add(recipe3); recipe4.RecipeProducts.Add(recipe4Product1); recipeForDbSetList.Add(recipe4); // fill db sets setUpDbSets(); ResultDataService resultDataService = new ResultDataService(dbContextCreator); List <Recipe> resultRecipeList = resultDataService.GetRecipes().ToList(); Assert.Equal(recipeForDbSetList, resultRecipeList); }
protected async void AddResult() { var result = await ResultDataService.Add(new Result() { EventId = Event.EventId }); Event.Results.Add(result); await EventDataService.Update(Event.EventId, Event); StateHasChanged(); }
public void ReturnOnlyTagsCompliant() { var ctx = GetContextWithData(); ctx.FridgeProducts.Add(fridge1Product1); ctx.RecipeProducts.Add(recipe1Product1); ctx.RecipeProducts.Add(recipe2Product1); ctx.RecipeProducts.Add(recipe3Product1); ctx.Recipes.Add(recipe1); ctx.Recipes.Add(recipe2); ctx.Recipes.Add(recipe3); ctx.Tags.Add(tag1); ctx.Tags.Add(tag2); ctx.Tags.Add(tag3); ctx.RecipeTags.Add(recipe1tag1); ctx.RecipeTags.Add(recipe2tag2); ctx.SaveChanges(); ResultDataService resultDataService = new ResultDataService(ctx, fridgeRepositoryMock.Object); List <Guid> tagsIds = new List <Guid> { tag1.Id }; List <Recipe> expectedList = new List <Recipe> { recipe1 }; SortByRecipeId(expectedList); List <Recipe> actualList = resultDataService.GetAllMatchingPublicPlusUserRecipes(firstUserGuid, tagsIds).ToList(); SortByRecipeId(actualList); actualList.ShouldBeEquivalentTo(expectedList); }
private void NoProductsAnywhereAllMatches() { var ctx = GetContextWithData(); ctx.Add(recipe1); ctx.Add(recipe2); ctx.Add(recipe3); ctx.SaveChanges(); ResultDataService resultDataService = new ResultDataService(ctx, fridgeRepositoryMock.Object); List <Recipe> expectedList = new List <Recipe> { recipe1, recipe2, recipe3 }; SortByRecipeId(expectedList); List <Recipe> actualList = resultDataService.GetAllMatchingPublicPlusUserRecipes(firstUserGuid).ToList(); SortByRecipeId(actualList); expectedList.ShouldBeEquivalentTo(actualList); }
protected void UpdateResultChanges(Result result) { ResultDataService.Update(result.ResultId, result); }
public void Setup() { _dataService = new ResultDataService(new SqlDirectService(ConfigurationManager.ConnectionStrings["db"].ConnectionString)); }