public void GetAllPatients() { // Arrange - set up the test var options = new DbContextOptionsBuilder <LaboratoryDbContext>() .UseInMemoryDatabase("LaboratoryDatabaseForTesting") .Options; using (var context = new LaboratoryDbContext(options)) { context.Patients.Add(new Patient() { FirstName = "Remus", LastName = "Pavelean", City = "Cluj-Napoca", Email = "*****@*****.**", Phone = "0752436680" }); context.Patients.Add(new Patient() { FirstName = "Anca", LastName = "Marcus", City = "Brasov", Email = "*****@*****.**", Phone = "0752406360" }); context.SaveChanges(); var patientRepository = new PatientRepository(context); var patientService = new PatientService(patientRepository); // Act - invoke the method we want to test var patients = patientService.ReadAll(); //Assert - verify that the action of the tested method behaved as expected Assert.Equal(2, patients.Count); Assert.Equal("Remus", patients.Find(p => p.Id == 1).FirstName); Assert.Equal("Anca", patients.Find(p => p.Id == 2).FirstName); } }
public ImgpostService(LaboratoryDbContext context) { this._context = context; }
public UserService(LaboratoryDbContext context) { this._context = context; }