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 GetNextStudent()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:    The initial set up is for the first element to be the current item.
            var result = db.NextStudent();

            //  Assert: We should be on the 2nd item, i.e. the last item.
            Assert.AreEqual(result.Firstname, "Nancy");
        }
        public void GetTheLastStudent()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:
            var result = db.LastStudent();

            //  Assert:
            Assert.AreEqual(result.Firstname, "Nancy");
        }
        public void GetPreviousStudentWhenAlreadyAtFirst()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:    The initial set up is for the first element to be the current item.
            var positionAtStart = db.FirstStudent();
            var result          = db.PreviousStudent(); // should move back to firstitem.

            //  Assert: We should be on the 2nd item, i.e. the last item.
            Assert.AreEqual(positionAtStart, result);
        }
        public void GetNextStudentWhenAlreadyAtEnd()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:    The initial set up is for the first element to be the current item.
            var positionAtEnd = db.NextStudent();
            var result        = db.NextStudent();

            //  Assert: We should be on the 2nd item, i.e. the last item.
            Assert.AreEqual(positionAtEnd, result);
        }
        public void GetStudentByIdNotFound()
        {
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:
            var  lastResult = db.LastStudent();
            long lastId     = lastResult.Id + 1;
            var  result     = db.GetStudentById(lastId);

            //  Assert:
            Assert.IsNull(result, "Should not find the id.");
        }
        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 InitialListHasTwoEntries()
        {
            //  Arrange:    Set up an intance of the Student Repository
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:        Perform the unit tests.
            List <StudentRegistrationApp.Model.Student> results = db.GetStudents();

            //  Assert: Result should be 2 items
            Assert.AreEqual(results.Count(), 2);
        }
        ////  The container for the custom content
        //private Popup settingsPopup;
        ////  desired width for the settingsUI. UI guidelines specify this
        ////  shuld be 346 or 646 depending on needs
        //private double settingsWidth = 646;
        ////  used to determine the correct height to ensure our custon UI fills the screen
        //private Rect windowBounds;


        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            //  Set up the datastore via the Repository for the moment.
            //  Here we would ultimately set up the 
            //  DI Container so that we can inject the instances.
            Model.IRepository Repository = new Model.StudentRepository();
            searchRepository = new Model.SearchRepository();
        }
        public void GetStudentTimByKey()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:
            var student = db.GetStudent("Tim", "Harrison");

            //  Assert
            Assert.AreEqual(student.Firstname, "Tim");
            Assert.AreEqual(student.Surname, "Harrison");
        }
        public void GetStudentTimByKey()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:
            var student = db.GetStudent("Tim", "Harrison");

            //  Assert
            Assert.AreEqual(student.Firstname, "Tim");
            Assert.AreEqual(student.Surname, "Harrison");
        }
        public void GetStudentByKeyThatDoesNotExist()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:
            var student = db.GetStudent("Fred", "Harrison");

            //  Assert
            Assert.IsNull(student);
            Assert.AreEqual(db.GetStudents().Count(), 2);
        }
        public void InitialListHasTwoEntries()
        {
            //  Arrange:    Set up an intance of the Student Repository
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:        Perform the unit tests.
            List<StudentRegistrationApp.Model.Student> results = db.GetStudents();

            //  Assert: Result should be 2 items
            Assert.AreEqual(results.Count(), 2);

        }
        public void GetLastStudentById()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();
            //  Act:
            var  lastResult = db.LastStudent();
            long lastId     = lastResult.Id;
            var  result     = db.GetStudentById(lastId);

            //  Assert:
            Assert.AreEqual(result, lastResult, "Should get the last record");
        }
        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 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 GetStudentByKeyThatDoesNotExist()
        {
            //  Arrange:
            var db = new StudentRegistrationApp.Model.StudentRepository();

            //  Act:
            var student = db.GetStudent("Fred", "Harrison");

            //  Assert
            Assert.IsNull(student);
            Assert.AreEqual(db.GetStudents().Count(), 2);
        }
        ////  The container for the custom content
        //private Popup settingsPopup;
        ////  desired width for the settingsUI. UI guidelines specify this
        ////  shuld be 346 or 646 depending on needs
        //private double settingsWidth = 646;
        ////  used to determine the correct height to ensure our custon UI fills the screen
        //private Rect windowBounds;


        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            //  Set up the datastore via the Repository for the moment.
            //  Here we would ultimately set up the
            //  DI Container so that we can inject the instances.
            Model.IRepository Repository = new Model.StudentRepository();
            searchRepository = new Model.SearchRepository();

            CheckFolders();
        }
        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 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 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 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);
        }
        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 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 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);
        }
        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 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 GetStudentByIdNotFound()
 {
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:
     var lastResult = db.LastStudent();
     long lastId = lastResult.Id + 1;
     var result = db.GetStudentById(lastId);
     //  Assert:
     Assert.IsNull(result, "Should not find the id.");
 }
        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 GetLastStudentById()
 {
     //  Arrange:
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:
     var lastResult = db.LastStudent();
     long lastId = lastResult.Id;
     var result = db.GetStudentById(lastId);
     //  Assert:
     Assert.AreEqual(result, lastResult, "Should get the last record");
 }
 public void GetTheLastStudent()
 {
     //  Arrange:
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:
     var result = db.LastStudent();
     //  Assert:
     Assert.AreEqual(result.Firstname, "Nancy");
 }
 public void GetPreviousStudentWhenAlreadyAtFirst()
 {
     //  Arrange:
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:    The initial set up is for the first element to be the current item.
     var positionAtStart = db.FirstStudent();
     var result = db.PreviousStudent();      // should move back to firstitem.
     //  Assert: We should be on the 2nd item, i.e. the last item.
     Assert.AreEqual(positionAtStart,result);
 }
 public void GetNextStudentWhenAlreadyAtEnd()
 {
     //  Arrange:
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:    The initial set up is for the first element to be the current item.
     var positionAtEnd = db.NextStudent();
     var result = db.NextStudent();
     //  Assert: We should be on the 2nd item, i.e. the last item.
     Assert.AreEqual(positionAtEnd, result);
 }
 public void GetNextStudent()
 {
     //  Arrange:
     var db = new StudentRegistrationApp.Model.StudentRepository();
     //  Act:    The initial set up is for the first element to be the current item.
     var result = db.NextStudent();
     //  Assert: We should be on the 2nd item, i.e. the last item.
     Assert.AreEqual(result.Firstname, "Nancy");
 }