public void Save_Update_InvalidStudent_NoName_Fail()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_appUser);
            VM = new StudentsPageVM(dbConName, new Student(), _appUser);
            VM.SelectedStudent = new Student(999, "", "*****@*****.**", "password", DateTime.Now.Date, 444);
            VM.FormContext     = FormContext.Update;
            //Act
            bool result    = VM.Save();
            int  newScount = 3;

            //Assert
            Assert.IsFalse(result);
            Assert.AreEqual(newScount, VM.Students.Count);
        }
        public void Save_New_Success()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_appUser);
            VM = new StudentsPageVM(dbConName, new Student(), _appUser);
            VM.SelectedStudent = new Student(999, "Student", "*****@*****.**", "Password", DateTime.Now.Date, 444);
            VM.FormContext     = FormContext.Create;
            //Act
            bool result    = VM.Save();
            int  newScount = 4;

            //Assert
            Assert.IsTrue(result);
            Assert.AreEqual(newScount, VM.Students.Count);
        }
        public void Save_Update_InvalidStudent_NoPassword_Fail()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_appUser);
            VM = new StudentsPageVM(dbConName, new Student(), _appUser);
            VM.SelectedStudent = VM.Students.Where(s => s.Id == 1701267).FirstOrDefault();
            VM.FormContext     = FormContext.Update;
            //Act
            VM.SelectedStudent.Password = null;
            bool result    = VM.Save();
            int  newScount = 3;

            //Assert
            Assert.IsFalse(result);
            Assert.AreEqual(newScount, VM.Students.Count);
        }
        public void Save_Update_Success()
        {
            //Arrange
            ClearDatabase();
            CreateMySessionTestData(_appUser);
            VM = new StudentsPageVM(dbConName, new Student(), _appUser);
            VM.SelectedStudent = VM.Students.Where(s => s.Id == 1701267).FirstOrDefault();
            VM.FormContext     = FormContext.Update;
            //Act
            VM.SelectedStudent.Name = "UpdatedValue";
            bool   result    = VM.Save();
            int    newScount = 3;
            string newName   = "UpdatedValue";

            //Assert
            Assert.IsTrue(result);
            Assert.AreEqual(newScount, VM.Students.Count);
            Assert.IsTrue(newName.Equals(VM.SelectedStudent.Name));
        }
        public void Save_Update_InvalidStudent_NoEmail_Fail()
        {
            //Arrange
            Lecturer       _appUser2 = new Lecturer(444, "Suzy", "*****@*****.**", "password", true, new DateTime(2019, 11, 28, 16, 22, 27, 813), 1234);;
            StudentsPageVM VM2       = new StudentsPageVM(dbConName, new Student(), _appUser2);

            ClearDatabase();
            CreateMySessionTestData(_appUser2);
            VM = new StudentsPageVM(dbConName, new Student(), _appUser);
            VM2.SelectedStudent      = VM.UnitOfWork.StudentRepo.Get(444);
            VM2.SelectedStudent.Name = "Updated";
            VM2.FormContext          = FormContext.Update;
            //Act
            bool result    = VM2.Save();
            int  newScount = 3;

            //Assert
            Assert.IsFalse(result);
            Assert.AreEqual(newScount, VM.Students.Count);
        }