コード例 #1
0
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
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);
        }
コード例 #12
0
        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);
        }