コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public ImgpostService(LaboratoryDbContext context)
 {
     this._context = context;
 }
コード例 #3
0
 public UserService(LaboratoryDbContext context)
 {
     this._context = context;
 }