public void GetAllStudents_WhenMultipleStudentsInRepository_ShouldReturnMultipleStudents() { var repository = new FakeRepository(); var studentEntity = new Student() { FirstName = "John", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity); var studentEntity2 = new Student() { FirstName = "Angel", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity2); var studentEntity3 = new Student() { FirstName = "William", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity3); var controller = new StudentsController(repository); IEnumerable <StudentModel> studentModels = controller.Get(); Assert.IsTrue(studentModels.Count() == 3); Assert.AreEqual(studentEntity3.FirstName, studentModels.Last().FirstName); }
public void GetSingleStudent_WhenStudentNotInRepository_ShouldReturnNull() { var repository = new FakeRepository(); var studentEntity = new Student() { FirstName = "John", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity); var studentEntity2 = new Student() { FirstName = "Angel", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity2); var studentEntity3 = new Student() { FirstName = "William", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity3); var controller = new StudentsController(repository); StudentModel studentModel = controller.Get(4); Assert.IsNull(studentModel); }
public void GetAllStudents_WhenSingleStudentInRepository_ShouldReturnSingleStudent() { var repository = new FakeRepository(); var studentEntity = new Student() { FirstName = "John", LastName = "Tomson", Age = 15, Grade = 9 }; repository.Add(studentEntity); var controller = new StudentsController(repository); IEnumerable <StudentModel> studentModels = controller.Get(); Assert.IsTrue(studentModels.Count() == 1); Assert.AreEqual(studentEntity.FirstName, studentModels.First().FirstName); }