public void Init() { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var connectionString = config["ConnectionStrings:DwapiConnectionDev"]; var liveSync = config["LiveSync"]; Uri endPointA = new Uri(liveSync); // this is the endpoint HttpClient will hit HttpClient httpClient = new HttpClient() { BaseAddress = endPointA, }; DapperPlusManager.AddLicense("1755;700-ThePalladiumGroup", "2073303b-0cfc-fbb9-d45f-1723bb282a3c"); if (!Z.Dapper.Plus.DapperPlusManager.ValidateLicense(out var licenseErrorMessage)) { throw new Exception(licenseErrorMessage); } _serviceProvider = new ServiceCollection() .AddDbContext <MnchContext>(o => o.UseSqlServer(connectionString)) .AddScoped <IDocketRepository, DocketRepository>() .AddScoped <IMasterFacilityRepository, MasterFacilityRepository>() .AddScoped <IFacilityRepository, FacilityRepository>() .AddScoped <IManifestRepository, ManifestRepository>() .AddScoped <IPatientMnchRepository, PatientMnchRepository>() .AddScoped <IAncVisitRepository, AncVisitRepository>() .AddScoped <IFacilityRepository, FacilityRepository>() .AddScoped <IMasterFacilityRepository, MasterFacilityRepository>() .AddScoped <IPatientMnchRepository, PatientMnchRepository>() .AddScoped <IManifestRepository, ManifestRepository>() .AddScoped <IAncVisitRepository, AncVisitRepository>() .AddScoped <IMnchService, MnchService>() .AddScoped <ILiveSyncService, LiveSyncService>() .AddScoped <IManifestService, ManifestService>() .AddSingleton <HttpClient>(httpClient) .AddMediatR(typeof(ValidateFacilityHandler)) .BuildServiceProvider(); _context = _serviceProvider.GetService <MnchContext>(); _context.Database.EnsureDeleted(); _context.Database.Migrate(); _context.MasterFacilities.AddRange(TestDataFactory.TestMasterFacilities()); var facilities = TestDataFactory.TestFacilities(); _context.Facilities.AddRange(facilities); _context.SaveChanges(); _context.MnchPatients.AddRange(TestDataFactory.TestClients(1, facilities.First(x => x.SiteCode == 1).Id)); _context.MnchPatients.AddRange(TestDataFactory.TestClients(2, facilities.First(x => x.SiteCode == 2).Id)); _context.SaveChanges(); //1, }
public void Init() { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var connectionString = config["ConnectionStrings:DwapiConnection"]; _serviceProvider = new ServiceCollection() .AddDbContext <MnchContext>(o => o.UseSqlServer(connectionString)) .AddTransient <IFacilityRepository, FacilityRepository>() .AddTransient <IManifestRepository, ManifestRepository>() .BuildServiceProvider(); _facilities = TestDataFactory.TestFacilityWithPatients(2); _manifests = TestDataFactory.TestManifests(2); _manifests[0].FacilityId = _facilities[0].Id; _manifests[1].FacilityId = _facilities[1].Id; _context = _serviceProvider.GetService <MnchContext>(); _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); _context.MasterFacilities.AddRange(TestDataFactory.TestMasterFacilities()); _context.Facilities.AddRange(_facilities); _context.Manifests.AddRange(_manifests); _context.SaveChanges(); }
public void Init() { _serviceProvider = new ServiceCollection() .AddDbContext <MnchContext>(o => o.UseInMemoryDatabase(Guid.NewGuid().ToString())) .AddScoped <IMasterFacilityRepository, MasterFacilityRepository>() .AddScoped <IFacilityRepository, FacilityRepository>() .AddMediatR(typeof(ValidateFacilityHandler)) .BuildServiceProvider(); _context = _serviceProvider.GetService <MnchContext>(); _context.MasterFacilities.Add(new MasterFacility(1, "XFacility", "XCounty")); _context.MasterFacilities.Add(new MasterFacility(2, "YFacility", "YCounty")); _context.Facilities.Add(new Facility(1, "XFacility District", 1)); _context.SaveChanges(); }