public void Test_AddPatient_AddsPatientToVet() { //Arrange DateTime dob = new DateTime(1986, 12, 5); Vet testVet = new Vet("Doctor Phil", "Headstuff"); testVet.Save(); Patient testPatient = new Patient("Larry", "hernia", "bird", dob); testPatient.Save(); Patient testPatient2 = new Patient("Jim", "ugly", "cow", dob); testPatient2.Save(); //Act testVet.AddPatient(testPatient); testVet.AddPatient(testPatient2); List <Patient> result = testVet.GetPatients(); List <Patient> testList = new List <Patient> { testPatient, testPatient2 }; //Assert CollectionAssert.AreEqual(testList, result); }
public ActionResult AddPatient(int vetId, int patientId) { Vet vet = Vet.Find(vetId); Patient patient = Patient.Find(patientId); vet.AddPatient(patient); return(RedirectToAction("Show", new { id = vetId })); }
public void GetPatients_RetrievesAllPatientsWithVet_PatientList() { //Arrange, Act Vet testVet = new Vet("Doctor Phil", "Headstuff"); testVet.Save(); DateTime dob = new DateTime(1986, 12, 5); Patient firstPatient = new Patient("Larry", "hernia", "bird", dob); firstPatient.Save(); testVet.AddPatient(firstPatient); Patient secondPatient = new Patient("barry", "hernia", "bird", dob); secondPatient.Save(); testVet.AddPatient(secondPatient); List <Patient> testPatientList = new List <Patient> { firstPatient, secondPatient }; List <Patient> resultPatientList = testVet.GetPatients(); //Assert CollectionAssert.AreEqual(testPatientList, resultPatientList); }
public void Delete_DeletesVetAssociationsFromDatabase_VetList() { //Arrange DateTime dob = new DateTime(1986, 12, 5); Patient testPatient = new Patient("Larry", "hernia", "bird", dob); testPatient.Save(); string testName = "Home stuff"; Vet testVet = new Vet("Doctor Phil", "Headstuff"); testVet.Save(); //Act testVet.AddPatient(testPatient); testVet.Delete(); List <Vet> resultPatientVets = testPatient.GetVets(); List <Vet> testPatientVets = new List <Vet> { }; //Assert CollectionAssert.AreEqual(testPatientVets, resultPatientVets); }
public void GetPatients_ReturnsAllVetPatients_PatientList() { //Arrange DateTime dob = new DateTime(1986, 12, 5); Vet testVet = new Vet("Doctor Phil", "Headstuff"); testVet.Save(); Patient testPatient1 = new Patient("Larry", "hernia", "bird", dob); testPatient1.Save(); Patient testPatient2 = new Patient("Jim", "ugly", "cow", dob); testPatient2.Save(); //Act testVet.AddPatient(testPatient1); List <Patient> savedPatients = testVet.GetPatients(); List <Patient> testList = new List <Patient> { testPatient1 }; //Assert CollectionAssert.AreEqual(testList, savedPatients); }