Esempio n. 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    dateEquality = (this.GetDate() == newStudent.GetDate());
         return(idEquality && nameEquality && dateEquality);
     }
 }
Esempio n. 2
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Student testStudent = new Student("Jasper", "07/24/2017");

            //Act
            testStudent.Save();
            Student savedStudent = Student.GetAll()[0];


            int result = savedStudent.GetId();
            int testId = testStudent.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Esempio n. 3
0
        public void Test_SaveAssignsIdToObject()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

            //Act
            Student savedStudent = Student.GetAll()[0];

            int result = savedStudent.GetId();
            int testId = testStudent.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Esempio n. 4
0
        public void AddStudent(Student newStudent)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand cmd = new SqlCommand("INSERT INTO students_courses (course_id, Student_id) VALUES (@CourseId, @StudentId);", conn);

            cmd.Parameters.Add(new SqlParameter("@CourseId", this.GetId()));
            cmd.Parameters.Add(new SqlParameter("@StudentId", newStudent.GetId()));

            cmd.ExecuteNonQuery();

            if (conn != null)
            {
                conn.Close();
            }
        }