public void CheckAllInformationIsCorrectedWhenTeacherInformationIsEdited()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newTeacher = new Teacher
                {
                    TeacherId = 5,
                    FirstName = "Jo",
                    LastName  = "Wong",
                    Email     = "*****@*****.**"
                };

                db.Teachers.Add(newTeacher);
                db.SaveChanges();
            }

            _crudManager.EditTeacher(5, "Alice", "Cheung", "*****@*****.**");

            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var selectedTeacher = db.Teachers.Where(t => t.TeacherId == 5).FirstOrDefault();
                Thread.Sleep(2000);
                Assert.AreEqual("Alice", selectedTeacher.FirstName);
                Assert.AreEqual("Cheung", selectedTeacher.LastName);
                Assert.AreEqual("*****@*****.**", selectedTeacher.Email);
            }
        }
Exemplo n.º 2
0
        public void NumberOfStudentsToDecreaseBy1WhenStudentIsDeleted()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newStudent = new Student
                {
                    StudentId           = 7,
                    FirstName           = "Lauren",
                    LastName            = "Pang",
                    Age                 = 22,
                    Allergies           = "N/A",
                    ParentName          = "Emy",
                    ParentContactNumber = "07123123123",
                    ParentEmail         = "*****@*****.**",
                    ClassId             = 6
                };

                db.Students.Add(newStudent);
                db.SaveChanges();

                var numberOfStudentsBefore = db.Students.Count();
                _crudManager.DeleteStudent(7);
                var numberOfStudentsAfter = db.Students.Count();
                Assert.AreEqual(numberOfStudentsAfter, numberOfStudentsBefore - 1);
            }
        }
 public void DeleteTeacher(int teacherID)
 {
     using (var db = new ChineseSchoolAdminSystemContext())
     {
         var selectedTeacher = db.Teachers.Where(s => s.TeacherId == teacherID).FirstOrDefault();
         db.Teachers.Remove(selectedTeacher);
         db.SaveChanges();
     }
 }
 public void DeleteStudent(int studentID)
 {
     using (var db = new ChineseSchoolAdminSystemContext())
     {
         var selectedStudent = db.Students.Where(s => s.StudentId == studentID).FirstOrDefault();
         db.Students.Remove(selectedStudent);
         db.SaveChanges();
     }
 }
        public void EditTeacher(int teacherID, string firstName, string lastName, string email)
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                SelectedTeacher           = db.Teachers.Where(t => t.TeacherId == teacherID).FirstOrDefault();
                SelectedTeacher.FirstName = firstName;
                SelectedTeacher.LastName  = lastName;
                SelectedTeacher.Email     = email;

                db.SaveChanges();
            }
        }
        public void AddTeacher(int teacherID, string firstName, string lastName, string email)
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newTeacher = new Teacher
                {
                    TeacherId = teacherID,
                    FirstName = firstName,
                    LastName  = lastName,
                    Email     = email
                };

                db.Teachers.Add(newTeacher);
                db.SaveChanges();
            }
        }
        public void Teardown()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var selectedTeacher =
                    from c in db.Teachers
                    where c.TeacherId == 5
                    select c;


                foreach (var c in selectedTeacher)
                {
                    db.Teachers.Remove(c);
                }

                db.SaveChanges();
            }
        }
        public void EditStudent(int studentID, string firstName, string lastName, int age, string allergies,
                                string parentName, string parentContactNumber, string parentEmail, int classID)
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                SelectedStudent                     = db.Students.Where(s => s.StudentId == studentID).FirstOrDefault();
                SelectedStudent.FirstName           = firstName;
                SelectedStudent.LastName            = lastName;
                SelectedStudent.Age                 = age;
                SelectedStudent.Allergies           = allergies;
                SelectedStudent.ParentName          = parentName;
                SelectedStudent.ParentContactNumber = parentContactNumber;
                SelectedStudent.ParentEmail         = parentEmail;
                SelectedStudent.ClassId             = classID;

                db.SaveChanges();
            }
        }
Exemplo n.º 9
0
        public void Teardown()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var selectedStudent =
                    from c in db.Students
                    where c.StudentId == 7
                    select c;


                foreach (var c in selectedStudent)
                {
                    db.Students.Remove(c);
                }

                db.SaveChanges();
            }
        }
        public void NumberOfTeachersDecreasesBy1WhenTeacherisDeleted()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newTeacher = new Teacher
                {
                    TeacherId = 5,
                    FirstName = "Jo",
                    LastName  = "Wong",
                    Email     = "*****@*****.**"
                };

                db.Teachers.Add(newTeacher);
                db.SaveChanges();

                var numberOfTeachersBefore = db.Teachers.Count();
                _crudManager.DeleteTeacher(5);
                var numberOfTeachersAfter = db.Teachers.Count();
                Assert.AreEqual(numberOfTeachersAfter, numberOfTeachersBefore - 1);
            }
        }
        public void AddStudent(int studentID, string firstName, string lastName, int age, string allergies,
                               string parentName, string parentContactNumber, string parentEmail, int classID)
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newStudent = new Student
                {
                    StudentId           = studentID,
                    FirstName           = firstName,
                    LastName            = lastName,
                    Age                 = age,
                    Allergies           = allergies,
                    ParentName          = parentName,
                    ParentContactNumber = parentContactNumber,
                    ParentEmail         = parentEmail,
                    ClassId             = classID
                };

                db.Students.Add(newStudent);
                db.SaveChanges();
            }
        }
Exemplo n.º 12
0
        public void CheckAllInformationIsCorrectedWhenStudentInformationIsEdited()
        {
            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var newStudent = new Student
                {
                    StudentId           = 7,
                    FirstName           = "Olivia",
                    LastName            = "Pang",
                    Age                 = 22,
                    Allergies           = "N/A",
                    ParentName          = "Emy",
                    ParentContactNumber = "07123123123",
                    ParentEmail         = "*****@*****.**",
                    ClassId             = 6
                };

                db.Students.Add(newStudent);
                db.SaveChanges();
            }

            _crudManager.EditStudent(7, "Lauren", "Chu", 20, "Nuts", "Tony Chu", "07789778899", "*****@*****.**", 5);

            using (var db = new ChineseSchoolAdminSystemContext())
            {
                var selectedStudent = db.Students.Where(s => s.StudentId == 7).FirstOrDefault();
                Thread.Sleep(2000);
                Assert.AreEqual("Lauren", selectedStudent.FirstName);
                Assert.AreEqual("Chu", selectedStudent.LastName);
                Assert.AreEqual(20, selectedStudent.Age);
                Assert.AreEqual("Nuts", selectedStudent.Allergies);
                Assert.AreEqual("Tony Chu", selectedStudent.ParentName);
                Assert.AreEqual("07789778899", selectedStudent.ParentContactNumber);
                Assert.AreEqual("*****@*****.**", selectedStudent.ParentEmail);
                Assert.AreEqual(5, selectedStudent.ClassId);
            }
        }