예제 #1
0
        public void RecipeRepositoryCanGetRecipe()
        {
            /* Begin Arrange */
            my_list.Add(new Recipe { RecipeName = "Soup", RecipeCreator = user1 });
            my_list.Add(new Recipe { RecipeName = "Meatloaf", RecipeCreator = user2 });
            ConnectMocksToDataSource();

            /* Leveraging the CreateBoard Method:
                 mock_boards.Setup(m => m.Add(It.IsAny<Board>())).Callback((Board b) => my_list.Add(b));
                 Board added_board = board_repo.CreateBoard(title, owner);
            */

            RecipeRepository recipe_repository = new RecipeRepository(mock_context.Object);
            /* Begin Act */
            List<Recipe> user_recipes = recipe_repository.GetRecipes(user1);
            /* Begin Assert */
            Assert.AreEqual(1, user_recipes.Count());
            Assert.AreEqual("Soup", user_recipes.First().RecipeName);
        }
예제 #2
0
        public void RecipeRepositoryCanGetRecipeCount()
        {
            /* Begin Arrange */

            var data = my_list.AsQueryable();

            //mock_boards.Object.Add(new Board { Title = "My Awesome Board", Owner = new ApplicationUser() });

            //var data = mock_boards.Object.AsQueryable();
            mock_recipes.As<IQueryable<Recipe>>().Setup(m => m.Provider).Returns(data.Provider);
            mock_recipes.As<IQueryable<Recipe>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            mock_recipes.As<IQueryable<Recipe>>().Setup(m => m.ElementType).Returns(data.ElementType);
            mock_recipes.As<IQueryable<Recipe>>().Setup(m => m.Expression).Returns(data.Expression);

            mock_context.Setup(m => m.Recipes).Returns(mock_recipes.Object);
            //mock_context.Object.SaveChanges(); // This saves something to the Database
            RecipeRepository recipe_repository = new RecipeRepository(mock_context.Object);
            /* End Arrange */

            /* Begin Act */
            int actual = recipe_repository.GetRecipeCount();
            /* End Act */

            /* Begin Assert */
            Assert.AreEqual(0, actual);
            /* End Assert */

            /* Begin Act */
            my_list.Add(new Recipe { RecipeName = "Soup" });
            mock_recipes.As<IQueryable<Recipe>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            /* End Act */

            /* Begin Assert */
            Assert.AreEqual(1, recipe_repository.GetRecipeCount());
            /* End Assert */
        }
예제 #3
0
        public void RecipeRepositoryEnsureThereAreZeroRecipes()
        {
            /* Begin Arrange */
            //testing for 0 recipes

            ConnectMocksToDataSource();
            RecipeRepository recipe_repo = new RecipeRepository(mock_context.Object);
            /* End Arrange */

            int expected = 0;
            int actual = recipe_repo.GetRecipeCount();
            Assert.AreEqual(expected, actual);
        }
예제 #4
0
 public void RecipeRepositoryEnsureICanCreateInstance()
 {
     RecipeRepository recipe = new RecipeRepository(mock_context.Object);
     Assert.IsNotNull(recipe);
 }
예제 #5
0
        public void RecipeRepositoryEnsureICanGetAllRecipes()
        {
            /* Begin Arrange */

            var recipe_lists = new List<RecipeList>
            {
                new RecipeList { Title = "My List", RecipeListId = 1}
            };

            my_list.Add(new Recipe { RecipeName = "Soup", RecipeCreator = user1, RecipeId = 1});
            my_list.Add(new Recipe { RecipeName = "Meatloaf", RecipeCreator = user2, RecipeId = 2});
            ConnectMocksToDataSource();
            RecipeRepository recipe_repo = new RecipeRepository(mock_context.Object);
            /* End Arrange */

            /* Begin Act */
            int expected = 2;
            int actual = (int)recipe_repo.GetAllRecipes()/*.Count*/;   // get this fixed
            /* End Act */

            /* Begin Assert */
            Assert.AreEqual(expected, actual);
            /* End Assert */
        }
예제 #6
0
        public void RecipeRepositoryEnsureCanDeleteRecipe()
        {
            /* Begin Arrange */
            my_list.Add(new Recipe { RecipeName = "Soup", RecipeCreator = user1 });
            my_list.Add(new Recipe { RecipeName = "Meatloaf", RecipeCreator = user2 });
            my_list.Add(new Recipe { RecipeName = "Cheese", RecipeCreator = user1 });
            ConnectMocksToDataSource();

            RecipeRepository recipe_repository = new RecipeRepository(mock_context.Object);
            /* End Arrange */

            /* Begin Act */
            recipe_repository.RemoveRecipe("Meatloaf");
            /* End Act */
            /* Begin Assert */
            Assert.AreEqual(2, recipe_repository.GetRecipeCount());
            /* End Assert */
        }
예제 #7
0
 public SpinController(RecipeRepository _repo)
 {
     repository = _repo;
 }
예제 #8
0
 public SpinController()
 {
     repository = new RecipeRepository();
 }
예제 #9
0
 public ProfileController(RecipeRepository _repo)
 {
     repository = _repo;
 }
예제 #10
0
 public ProfileController()
 {
     repository = new RecipeRepository();
 }