Ejemplo n.º 1
0
 public void AddIngredientCustom_ShouldWork()
 {
     RunOnDatabase(async s =>
     {
         DestroyDatabase();
         // Arrange
         var fridgeRepo    = new FridgeRepository(s);
         var ingredCatRepo = new IngredientsCategoryRepository(s);
         var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
         var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
         IEnumerable <IngredientCategory> categories = GetDefaultCategories();
         // Act
         Populate(s);
         int count = ingredRepo.GetAll().Result.Count();
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "t", "ms", "new", 1, 1, 1);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "First Category", "i3", "cup", 1, 1, 1);
         //await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "Another Category", "i3", "cup", 1, 1, 1);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "asfasfasfasfy", "i5", "cup", 1, 1, 1);
         // Assert
         Assert.AreEqual(count + 3, ingredRepo.GetAll().Result.Count());
     });
 }
Ejemplo n.º 2
0
 public void GetSpecificCategory_ShouldWork()
 {
     RunOnDatabase(async s =>
     {
         DestroyDatabase();
         // Arrange
         var fridgeRepo    = new FridgeRepository(s);
         var ingredCatRepo = new IngredientsCategoryRepository(s);
         var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
         var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
         IEnumerable <IngredientCategory> categories = GetDefaultCategories();
         // Act
         Populate(s);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "asfasfasfasfy", "cup", "i5", 1, 1, 1);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "other-ingredients", "cup", "i6", 1, 1, 1);
         var res  = await ingredRepo.GetSpecificCategory("i5");
         var res2 = await ingredRepo.GetSpecificCategory("i6");
         var res1 = await ingredRepo.GetSpecificCategory("null");
         // Assert
         Assert.AreEqual(res, ingredCatRepo.GetByName("asfasfasfasfy").Result.Id);
         Assert.AreEqual(res2, null);
         Assert.AreEqual(null, res1);
     });
 }
Ejemplo n.º 3
0
 public void GetByVotesNumber_Should_Work_Ok()
 {
     RunOnDatabase(async s =>
     {
         DestroyDatabase();
         // Arrange
         var fridgeRepo    = new FridgeRepository(s);
         var ingredCatRepo = new IngredientsCategoryRepository(s);
         var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
         var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
         // Act
         Populate(s);
         var res = await recipeRepo.GetByVotesNumber(4, recipeRepo.GetAll());
         // Assert
         Assert.IsTrue(0 == res.ToList().Count);
     });
 }
Ejemplo n.º 4
0
        public void GetByPreparationTime_Should_Work_Ok()
        {
            RunOnDatabase(async s =>
            {
                DestroyDatabase();
                // Arrange
                var fridgeRepo    = new FridgeRepository(s);
                var ingredCatRepo = new IngredientsCategoryRepository(s);
                var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
                var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
                // Act
                Populate(s);

                var res = await recipeRepo.GetByPrepatationTime(25, recipeRepo.GetAll());

                // Assert
                Assert.AreEqual(1, res.ToList().Count);
            });
        }
Ejemplo n.º 5
0
        public void Given_Repository_When_Get_By_Recipe_ShouldBe_Correct()
        {
            RunOnDatabase(async s =>
            {
                DestroyDatabase();
                // Arrange
                var fridgeRepos    = new FridgeRepository(s);
                var categoryRepo   = new IngredientsCategoryRepository(s);
                var ingredientRepo = new IngredientsRepository(s, categoryRepo, fridgeRepos);
                var recipeRepo     = new RecipesRepository(s, fridgeRepos, ingredientRepo);

                // Act
                Populate(s);
                var data = await fridgeRepos.GetByRecipe(recipeRepo.GetByName("r1", recipeRepo.GetAll()).Result.First().Id);

                // Assert
                Assert.AreEqual(3, data.ToList().Count);
            });
        }
Ejemplo n.º 6
0
        public void GetByOnlyIngredients_Should_Work_Ok()
        {
            RunOnDatabase(async s =>
            {
                DestroyDatabase();
                // Arrange
                var fridgeRepo    = new FridgeRepository(s);
                var ingredCatRepo = new IngredientsCategoryRepository(s);
                var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
                var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
                // Act
                Populate(s);
                List <Ingredient> igToAdd = new List <Ingredient>();
                igToAdd.Add(ingredRepo.GetByName("i1").Result.First());
                var res = await recipeRepo.GetByOnlyIngredients(igToAdd, recipeRepo.GetAll());

                // Assert
                Assert.AreEqual(1, res.ToList().Count);
            });
        }
Ejemplo n.º 7
0
 // GET: Recipes
 public ActionResult List()
 {
     return(View(repository.GetAll()));
 }
Ejemplo n.º 8
0
 internal IEnumerable <Recipe> GetAll()
 {
     return(_repo.GetAll());
 }
Ejemplo n.º 9
0
 public ActionResult Index()
 {
     ViewBag.Title = "RecipeSearch";
     return(View(recipes.GetAll().Take(8)));
 }
Ejemplo n.º 10
0
        public void ExcludesIngredients_Should_Work_Ok()
        {
            RunOnDatabase(async s =>
            {
                DestroyDatabase();
                // Arrange
                var fridgeRepo    = new FridgeRepository(s);
                var ingredCatRepo = new IngredientsCategoryRepository(s);
                var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
                var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
                // Act
                Populate(s);
                List <Ingredient> igToAdd = new List <Ingredient>();
                igToAdd.Add(ingredRepo.GetByName("i1").Result.First());
                var res = await recipeRepo.ExcludesTheseIngredients(recipeRepo.GetByName("r1", recipeRepo.GetAll()).Result.First().Id, igToAdd);

                // Assert
                Assert.AreEqual(false, res);
            });
        }
Ejemplo n.º 11
0
 public void ContainsIngredient_Should_Work_Ok()
 {
     RunOnDatabase(async s =>
     {
         DestroyDatabase();
         // Arrange
         var fridgeRepo    = new FridgeRepository(s);
         var ingredCatRepo = new IngredientsCategoryRepository(s);
         var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
         var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
         // Act
         Populate(s);
         var res = await recipeRepo.ContainsIngredient(recipeRepo.GetByName("r1", recipeRepo.GetAll()).Result.First().Id, ingredRepo.GetByName("i1").Result.First().Id);
         // Assert
         Assert.IsTrue(res);
     });
 }