예제 #1
0
        public void ShouldReturnSomeRecipeWhenInvokeIndexMethodAndRepositoryReturnSomeRecipe()
        {
            var size = 2;

            _recipeRepositoryMock.Setup(c => c.GetAll())
            .Returns(BuilderRecipes(size).AsQueryable());

            var recipes = _recipesController.Index();

            Assert.AreEqual(size, recipes.Count());
        }
예제 #2
0
        public void GetAllRecipes_Test()
        {
            mockRepo.Setup(repo => repo.Recipes.FindAll()).Returns(GetRecipes());
            var controllerActionResult = recipeController.Index();

            Assert.NotNull(controllerActionResult);
            Assert.IsType <ViewResult>(controllerActionResult);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public void Index()
        {
            // Arrange
            RecipesController controller = new RecipesController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
예제 #6
0
        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();
        }
예제 #7
0
        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);
        }
예제 #8
0
 protected override void When()
 {
     _actionResult = _controller.Index();
 }