public void Get_patient_by_id() { // Arrange string firstName = "Sal"; string lastName = "Abruscato"; DateTime appointmentDate = DateTime.Now; DatabaseTools.AddPatientToDatabase(firstName, lastName, appointmentDate); Guid patientId = DatabaseTools.GetPatientFromDatabase(firstName, lastName).First().Id; // Act PatientEntity patient = _patientDal.GetPatientById(patientId); // Assert StringAssert.Contains(patient.FirstName, firstName); StringAssert.Contains(patient.LastName, lastName); Assert.IsNotEmpty(patient.Appointments); Assert.AreEqual(patient.Appointments.First().Date.Date, appointmentDate.Date); }
public void Add_patient_to_database() { // Arrange string firstName = "Peter"; string lastName = "Steele"; string pesel = "62010417694"; DateTime appointmentDate = DateTime.Now; // Act var patient = new PatientEntity { FirstName = firstName, LastName = lastName, Pesel = pesel }; patient.AddAppointment(new AppointmentEntity { Date = appointmentDate }); _patientDal.SaveOrUpdatePatient(patient); IList <PatientEntity> query = DatabaseTools.GetPatientFromDatabase(firstName, lastName); // Assert Assert.IsNotNull(query); Assert.IsNotEmpty(query); Assert.IsTrue(query.Count == 1); PatientEntity result = query.First(); StringAssert.Contains(result.FirstName, firstName); StringAssert.Contains(result.LastName, lastName); ICollection <AppointmentEntity> appointments = result.Appointments; Assert.IsNotEmpty(appointments); Assert.IsTrue(appointments.Count == 1); Assert.That(result.Pesel, Is.EqualTo(pesel)); }
public void Delete_patient_from_database() { // Arrange string firstName = "Josh"; string lastName = "Silver"; DateTime appointmentDate = DateTime.Now; DatabaseTools.AddPatientToDatabase(firstName, lastName, appointmentDate); IList <PatientEntity> patients = DatabaseTools.GetPatientFromDatabase(firstName, lastName); // Act _patientDal.DeletePatient(patients.First()); // Assert IList <PatientEntity> patientsAfterDelete = DatabaseTools.GetPatientFromDatabase(firstName, lastName); Assert.IsNotNull(patientsAfterDelete); Assert.IsEmpty(patientsAfterDelete); IList <AppointmentEntity> appointments = DatabaseTools.GetAllAppointments(); Assert.IsNotNull(appointments); Assert.IsEmpty(appointments); }