public async Task Index_ShouldReturnView()
        {
            //Arrange

            //_repoMock.Setup(x => x.GetAll()).Returns(list.AsQueryable());
            //Act
            var result = await _controller.Index();

            //Assert
            Assert.IsType <ViewResult>(result);
        }
        public void Teachers_Controller_Test_On_Index()
        {
            //Arrange
            var repo = Substitute.For <IRepository>();
            ICollection <Teacher> expectedTeachers = new[] { new Teacher() };

            repo.GetAll <Teacher>().Returns(expectedTeachers);
            var sut = new TeachersController(repo);

            //Act
            var actual = sut.Index().Result as ViewResult;

            //Assert
            Assert.IsInstanceOfType(actual, typeof(ViewResult));
            var viewResult = actual;

            Assert.AreEqual(expectedTeachers, viewResult.Model);
        }
Ejemplo n.º 3
0
 public void SetupContext()
 {
     controller = new TeachersController();
     result     = controller.Index() as ViewResult;
 }