public void Controller_Skills_Index_Default_Should_Pass()
        {
            // Arrange
            SkillsController controller = new SkillsController();

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

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Example #2
0
        public void IndexTest()
        {
            //testing only positive case as the UserNotFound case is nearly impossible to mock and it is unlikely to happen because of the way .Net MVC is set up
            mockSkillService.Setup(service => service.GetAll()).Returns(this.skills);
            mockSkillService.Setup(service => service.GetMySkills(It.IsAny <string>())).Returns(this.userSkills);
            var controller = new SkillsController(mockSkillService.Object);

            controller.ControllerContext = this.controllerContext;
            var result     = controller.Index();
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.IsAssignableFrom <Tuple <List <Skill>, List <Skill>, Skill> >(viewResult.ViewData.Model);


            mockSkillService.Reset(); //clearing up mock
        }
Example #3
0
        public async Task IndexTest()
        {
            var mockRepo = new Mock <ISkillRepository>();

            mockRepo.Setup(repo => repo.GetAll()).ReturnsAsync(TestData.Skills);
            var mockServ   = new Mock <ISkillService>();
            var controller = new SkillsController(mockServ.Object, mockRepo.Object);

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

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
            var viewResult = result as ViewResult;
            var model      = viewResult.ViewData.Model;

            Assert.IsNotNull(model);
        }