Beispiel #1
0
 public override bool Equals(System.Object otherStudent)
 {
     if (!(otherStudent is Student))
     {
         return(false);
     }
     else
     {
         Student newStudent             = (Student)otherStudent;
         bool    idEquality             = this.GetId() == newStudent.GetId();
         bool    nameEquality           = this.GetName() == newStudent.GetName();
         bool    enrollmentDateEquality = this.GetEnrollmentDate() == newStudent.GetEnrollmentDate();
         bool    departmentIdEqualtiy   = this.GetDepartmentId() == newStudent.GetDepartmentId();
         return(idEquality && nameEquality && enrollmentDateEquality);
     }
 }
        public void Test_Add_AddStudentToDepartment()
        {
            //Arrange
            Department testDepartment = new Department("English");

            testDepartment.Save();
            Student testStudent = new Student("Britton", "2010-09-01", testDepartment.GetId());

            testStudent.Save();

            //Act
            testDepartment.AddStudent(testStudent.GetId());
            int result   = testDepartment.GetId();
            int expected = testStudent.GetDepartmentId();

            //Assert
            Assert.Equal(expected, result);
        }