public void T5_FindStudentInDatabase() { DateTime fakeTime=new DateTime(2016,08,02); Student newStudent = new Student("Steve", fakeTime); newStudent.Save(); Student foundStudent = Student.Find(newStudent.GetId()); Assert.Equal(newStudent, foundStudent); }
public void AddStudents(Student newStudent) { SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO students_courses (student_id, course_id) VALUES (@StudentId,@CourseId)",conn); SqlParameter studentIdParameter = new SqlParameter(); studentIdParameter.ParameterName= "@StudentId"; studentIdParameter.Value= newStudent.GetId(); SqlParameter courseIdParameter = new SqlParameter(); courseIdParameter.ParameterName= "@CourseId"; courseIdParameter.Value= this.GetId(); cmd.Parameters.Add(studentIdParameter); cmd.Parameters.Add(courseIdParameter); cmd.ExecuteNonQuery(); if(conn != null) { conn.Close(); } }