Esempio n. 1
0
        public void TestIndexAndFullName()
        {
            var studentTestData = new List <Student>()
            {
                new Student {
                    id = 1, Name = "Andrei", Surname = "Andrei", CNP = "0000000000001", Email = "*****@*****.**"
                },
                new Student {
                    id = 2, Name = "Ion1", Surname = "Gheorghe1", CNP = "0000000000002", Email = "*****@*****.**"
                },
            };
            var students = MockDbSet(studentTestData);
            //Set up mocks for db sets
            var dbContext = new Mock <IDbContext>();

            dbContext.Setup(m => m.StudentViewModel).Returns(students.Object);

            var studentsController = new StudentController(dbContext.Object, null, null, null, null);

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

            //Assert
            Assert.IsTrue(results.Count == 2);
            Assert.IsTrue(results.ToArray()[0].FullName == "Andrei Andrei");
        }