public IList<Models.Patient> GetAllPatients() { using (var db = new EReferralContext()) { return db.Patients.ToList(); } }
public Patient AddPatient(Patient patient) { using (var db = new EReferralContext()) { var returnedPatient = db.Patients.Add(patient); db.SaveChanges(); return returnedPatient; } }
public void GetAllPatients_Should_Return_Patients() { // Arrange using (var context = new EReferralContext()) { context.Patients.Add(new Patient { Email = "*****@*****.**" }); context.Patients.Add(new Patient { Email = "*****@*****.**" }); context.SaveChanges(); } var service = new ReferralService(); // Act var patients = service.GetAllPatients(); // Assert patients.ShouldNotBeNull(); patients.Count.ShouldEqual(2); }