public void FindStudentFredDoesNotExist() { // Arrange: var db = new StudentRegistrationApp.Model.StudentRepository(); // Act: var result = db.SearchStudents("Fred", "Firstname"); // Assert: Nothing returned, Student Fred does not exist. Assert.AreEqual(result.Count(), 0); }
public void FindStudentNancy() { // Arrange: var db = new StudentRegistrationApp.Model.StudentRepository(); // Act: var result = db.SearchStudents("Nancy", "Firstname"); // Assert: Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result[0].Firstname, "Nancy", "Firstname"); }
public void DeleteStudentNancyWrongSurname() { // Arrange: var db = new StudentRegistrationApp.Model.StudentRepository(); // Nancy has different Surname var studentNancy = new StudentRegistrationApp.Model.Student(); studentNancy.Firstname = "Nancy"; studentNancy.Surname = "Fergusson"; studentNancy.DOB = new DateTime(1955, 9, 27); // Act: Should not delete nancy as Surname doesn't match db.DeleteStudent(studentNancy); // Still find record Nancy. var result = db.SearchStudents("Nancy", "Firstname"); // Assert: Still finds NAncy as it's not beed deleted. Assert.AreEqual(result.Count(), 1); }
public void DeleteStudentNancy() { // Arrange: var db = new StudentRegistrationApp.Model.StudentRepository(); var studentNancy = new StudentRegistrationApp.Model.Student(); studentNancy.Firstname = "Nancy"; studentNancy.Surname = "Harrison"; studentNancy.DOB = new DateTime(1955, 9, 27); // Act db.DeleteStudent(studentNancy); var result = db.SearchStudents("Nancy", "Firstname"); // Assert: Assert.AreEqual(result.Count(), 0); }
public void UpdateStudentTimNameChangeWhichShouldFail() { // Arrange; var db = new StudentRegistrationApp.Model.StudentRepository(); var student = new StudentRegistrationApp.Model.Student() { Firstname = "Tim Peter", Surname = "Harrison", DOB = new DateTime(1960, 2, 1), YearOfStudy = StudentRegistrationApp.Model.YearOfStudyEnum.Third }; // Act: db.UpdateStudent(student); // Assert: Tim is still at second year, as the update should've failed. var result = db.SearchStudents("Tim", "Firstname"); Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result[0].YearOfStudy, StudentRegistrationApp.Model.YearOfStudyEnum.Second); }
public void UpdateStudentTim() { // Arrange; var db = new StudentRegistrationApp.Model.StudentRepository(); var student = new StudentRegistrationApp.Model.Student() { Firstname = "Tim", Surname = "Harrison", DOB = new DateTime(1960, 2, 1), YearOfStudy = StudentRegistrationApp.Model.YearOfStudyEnum.Third }; // Act: db.UpdateStudent(student); // Assert: Tim is now in Third Year of Study var result = db.SearchStudents("Tim", "Firstname"); Assert.AreEqual(result.Count(), 1); Assert.AreEqual(result[0].YearOfStudy, StudentRegistrationApp.Model.YearOfStudyEnum.Third); }