Beispiel #1
0
        public void TestIndexAndFullName()
        {
            var teacherTestData = new List <Teacher>()
            {
                new Teacher {
                    Id = "1", FirstName = "Ion", LastName = "Gheorghe", Email = "*****@*****.**", Courses = new List <CourseModel>()
                },
                new Teacher {
                    Id = "2", FirstName = "Ion1", LastName = "Gheorghe1", Email = "*****@*****.**", Courses = new List <CourseModel>()
                },
                new Teacher {
                    Id = "3", FirstName = "Ion2", LastName = "Gheorghe2", Email = "*****@*****.**", Courses = new List <CourseModel>()
                },
                new Teacher {
                    Id = "4", FirstName = "Ion3", LastName = "Gheorghe3", Email = "*****@*****.**", Courses = new List <CourseModel>()
                },
            };
            var teachers = MockDbSet(teacherTestData);
            //Set up mocks for db sets
            var dbContext = new Mock <IDbContext>();

            dbContext.Setup(m => m.TeacherViewModel).Returns(teachers.Object);

            var teacherController = new TeacherController(dbContext.Object, null, null, null);

            //Act
            var results = teacherController.DoIndex();

            //Assert
            Assert.IsTrue(results.Count == 4);
            Assert.IsTrue(results.ToArray()[0].FullName == "Gheorghe Ion");
        }