public void UpdateStudentFredDoesNotExist() { // Arrange; var db = new StudentRegistrationApp.Model.StudentRepository(); var student = new StudentRegistrationApp.Model.Student() { Firstname = "Fred", 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 results = db.GetStudents(); Assert.AreEqual(results.Count(), 2); Assert.AreEqual(results[0].Firstname, "Tim"); Assert.AreEqual(results[0].YearOfStudy, StudentRegistrationApp.Model.YearOfStudyEnum.Second); Assert.AreEqual(results[1].Firstname, "Nancy"); Assert.AreEqual(results[1].YearOfStudy, StudentRegistrationApp.Model.YearOfStudyEnum.First); }
public void AddStudentToList() { // Arrange; var db = new StudentRegistrationApp.Model.StudentRepository(); var student = new StudentRegistrationApp.Model.Student() { Firstname = "Jude", Surname = "Comber", DOB = new DateTime(1963, 9, 26), YearOfStudy = StudentRegistrationApp.Model.YearOfStudyEnum.First }; // Act: db.AddStudent(student); List<StudentRegistrationApp.Model.Student> results = db.GetStudents(); // Assert: Assert.AreEqual(results.Count(), 3); }
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 AddStudentToList() { // Arrange; var db = new StudentRegistrationApp.Model.StudentRepository(); var student = new StudentRegistrationApp.Model.Student() { Firstname = "Jude", Surname = "Comber", DOB = new DateTime(1963, 9, 26), YearOfStudy = StudentRegistrationApp.Model.YearOfStudyEnum.First }; // Act: db.AddStudent(student); List <StudentRegistrationApp.Model.Student> results = db.GetStudents(); // Assert: Assert.AreEqual(results.Count(), 3); }
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); }