public void Test5_FindId() { Student newStudent = new Student ("Rick","2016-1-1"); newStudent.Save(); Student findStudent = Student.Find(newStudent.GetId()); Assert.Equal(findStudent, newStudent); }
public void Test4_SaveStudent() { //Arrange Student newStudent = new Student("Russ", "2016-1-1"); newStudent.Save(); //ACt List<Student> allStudents = Student.GetAll(); Console.WriteLine(allStudents.Count); //assert Assert.Equal(newStudent, allStudents[0]); }
public HomeModule() { Get["/"] = _ => { return View["index.cshtml"]; }; Get["/students"] = _ => { List<Student> allStudents = Student.GetAll(); return View["students.cshtml", allStudents]; }; Get["/students/new"] = _ => { return View["add_student.cshtml"]; }; Post["/students/new"] = _ => { Student newStudent = new Student(Request.Form["student-name"],Request.Form["student-doe"]); newStudent.Save(); List<Student> allStudents= Student.GetAll(); return View["students.cshtml", allStudents]; }; Get["/students/delete/{id}"] = parameters => { Student SelectedStudent = Student.Find(parameters.id); return View["confirm_student_delete.cshtml", SelectedStudent]; }; Get["students/edit/{id}"] = parameters => { Student SelectedStudent = Student.Find(parameters.id); return View["student_edit.cshtml", SelectedStudent]; }; Patch["students/edit/{id}"] = parameters => { Student SelectedStudent = Student.Find(parameters.id); SelectedStudent.Update(Request.Form["student-name"]); return View["index.cshtml"]; }; Delete["/students/delete/{id}"] = parameters => { Student SelectedStudent = Student.Find(parameters.id); SelectedStudent.Delete(); return View["index.cshtml"]; }; Post["/students/delete"] = _ => { Student.DeleteAll(); return View["index.cshtml"]; }; }
public void AddCourse_AddsCourseToStudent_True() { Course newCourse = new Course("Ryan", "ryan101"); newCourse.Save(); Student newStudent = new Student("Ryan", newDateTime); newStudent.Save(); newStudent.AddCourse(newCourse); List <Course> expected = new List <Course> { newCourse }; List <Course> result = newStudent.GetCourses(); Assert.Equal(expected, result); }
public void Save_SavesToDatabase_true() { //Arrange Student testStudent = new Student("Jimmy", newDateTime); testStudent.Save(); //Act List <Student> result = Student.GetAll(); List <Student> testList = new List <Student> { testStudent }; //Assert Assert.Equal(testList, result); }
public void AddStudent_AddsStudentToCourse_True() { Student newStudent = new Student("Ryan", newDateTime); newStudent.Save(); Course newCourse = new Course("Ryan", "Ryan101"); newCourse.Save(); newCourse.AddStudent(newStudent); List <Student> expected = new List <Student> { newStudent }; List <Student> result = newCourse.GetStudents(); Assert.Equal(expected, result); }
public void Delete_DeletesAssociation_True() { Student newStudent = new Student("Ryan", newDateTime); newStudent.Save(); Course newCourse = new Course("Ryan", "Ryan101"); newCourse.Save(); newStudent.AddCourse(newCourse); newStudent.Delete(); List <Course> result = newStudent.GetCourses(); List <Course> expected = new List <Course> { }; Assert.Equal(expected, result); }
public void Course_AddStudent_AddsStudentToCourse() { Course newCourse = new Course("Computer Science", "CS101"); newCourse.Save(); Student newStudent1 = new Student("David", new DateTime(2015, 05, 12)); newStudent1.Save(); Student newStudent2 = new Student("John", new DateTime(2016, 05, 22)); newStudent2.Save(); newCourse.AddStudent(newStudent1); newCourse.AddStudent(newStudent2); List <Student> testList = newCourse.GetStudents(); List <Student> controlList = new List <Student> { newStudent1, newStudent2 }; Assert.Equal(controlList, testList); }
public void Student_AddCourse_AddCourseToStudent() { Student newStudent = new Student("David", new DateTime(2015, 05, 12)); newStudent.Save(); Course firstCourse = new Course("Computer Science", "CS101"); firstCourse.Save(); Course secondCourse = new Course("Computer Science 2", "CS102"); secondCourse.Save(); newStudent.AddCourse(firstCourse); newStudent.AddCourse(secondCourse); List <Course> studentCourses = newStudent.GetCourses(); List <Course> controlCourses = new List <Course> { firstCourse, secondCourse }; Assert.Equal(controlCourses, studentCourses); }
public void Test7_DeleteOneStudent() { Student firstStudent = new Student("Russ","2016-1-1"); firstStudent.Save(); Student secondStudent = new Student("Bob", "2016-1-1"); secondStudent.Save(); firstStudent.Delete(); List<Student> allStudents = Student.GetAll(); List<Student> afterDeleteFristStudent = new List<Student> {secondStudent}; Assert.Equal(afterDeleteFristStudent, allStudents); }
public void Test6_UpdateStudent_Database() { Student newStudent = new Student("Rouz","2016-1-1"); newStudent.Save(); newStudent.Update("mike"); string result = newStudent.GetName(); Assert.Equal("mike", result); }