public void ShouldReturnSomeRecipeWhenInvokeIndexMethodAndRepositoryReturnSomeRecipe() { var size = 2; _recipeRepositoryMock.Setup(c => c.GetAll()) .Returns(BuilderRecipes(size).AsQueryable()); var recipes = _recipesController.Index(); Assert.AreEqual(size, recipes.Count()); }
public void GetAllRecipes_Test() { mockRepo.Setup(repo => repo.Recipes.FindAll()).Returns(GetRecipes()); var controllerActionResult = recipeController.Index(); Assert.NotNull(controllerActionResult); Assert.IsType <ViewResult>(controllerActionResult); }
public void IndexTest() { recipesRepo.Setup(repo => repo.GetAllRecipes()).Returns(recipes); var controller = new RecipesController(null, null, recipesRepo.Object, null, null, null, null); var result = controller.Index() as ViewResult; Assert.AreEqual(result.Model, recipes); }
public async Task Index() { var controller = new RecipesController(_service.Object); var result = await controller.Index(); var okObjectResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <Recipe> >(okObjectResult.Value); Assert.Single(model); }
public void Index() { // Arrange RecipesController controller = new RecipesController(); // Act ViewResult result = controller.Index() as ViewResult; // Assert Assert.IsNotNull(result); }
public void IndexTestNoRepository() { recipesRepo.Setup(repo => repo.GetAllRecipes()).Returns( new List <Recipe>() { new Recipe() { } }); var controller = new RecipesController(null, null, null, null, null, null, null); controller.Index(); }
public async Task IndexRecipesController() { var context = GetInMemoryDbMetData(); var controller = new RecipesController(context, _hostingEnvironment); var result = await controller.Index(); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <List <Recipe> >(viewResult.ViewData.Model); Assert.Equal(2, model.Count); Assert.Equal("Bakery", model[0].Category); Assert.NotNull(viewResult); }
protected override void When() { _actionResult = _controller.Index(); }