public void Task_Index_Return_ViewResult()
        {
            var controller = new BrandController(context);

            IActionResult data = controller.Index();

            Assert.IsType <ViewResult>(data);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            Brand b = new Brand();

            Assert.Throws <NullReferenceException>(() => {
                IActionResult result = controller.Index();
                Assert.NotNull(result);
                Assert.IsType <Brand>(b.BrandId);
                Assert.NotNull(b.BrandName);
                Assert.NotNull(b.BrandDescription);
            });
        }
Ejemplo n.º 3
0
        public async Task Index_ReturnsAViewResult_WithListOfBrands()
        {
            // Arrange
            var brands = GetListOfBrands();

            mockBrandRepo.Setup(x => x.GetAllIncludeAsync(It.IsAny <Expression <Func <Brand, object> >[]>())).ReturnsAsync(brands);

            mockUOW.Setup(x => x.Repository <Brand>()).Returns(mockBrandRepo.Object);

            var controller = new BrandController(mockUOW.Object);

            // Act
            var result = await controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <List <BrandListViewModel> >(viewResult.ViewData.Model);

            Assert.Equal(2, model.Count);
        }