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); }
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 */ }
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 */ }