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); } }
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); }
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); }
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(); } }