protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureTestServices(services => { Mock <IRegistrationNotifier> registrationNotifier = new Mock <IRegistrationNotifier>(); string connectionString = CreateConnectionStringFromEnvironment(); var patientAccountRepository = new PatientAccountSqlRepository(new UserSqlTestContextFactory(connectionString)); var patientAccountService = new PatientAccountService(patientAccountRepository); var patientRegistrationService = new PatientRegistrationService(patientAccountService, registrationNotifier.Object); services.Add(new ServiceDescriptor(typeof(IPatientRegistrationService), patientRegistrationService)); }); }
private void AddServices(IServiceCollection services) { var cityRepository = new CitySqlRepository(GetContextFactory()); var cityService = new CityService(cityRepository); services.Add(new ServiceDescriptor(typeof(CityService), cityService)); var countryRepository = new CountrySqlRepository(GetContextFactory()); var countryService = new CountryService(countryRepository); services.Add(new ServiceDescriptor(typeof(CountryService), countryService)); var doctorRepositry = new DoctorSqlRepository(GetContextFactory()); var doctorService = new DoctorService(doctorRepositry); services.Add(new ServiceDescriptor(typeof(DoctorService), doctorService)); var patientRepository = new PatientSqlRepository(GetContextFactory()); var patientAccountRepository = new PatientAccountSqlRepository(GetContextFactory()); var registrationNotifier = new RegistrationNotifier( "http://" + Environment.GetEnvironmentVariable("PSW_API_GATEWAY_HOST") + ":" + Environment.GetEnvironmentVariable("PSW_API_GATEWAY_PORT") + "/api/patient/activate/"); var patientAccountService = new PatientAccountService(patientAccountRepository); var patientRegistrationService = new PatientRegistrationService(patientAccountService, registrationNotifier); var patientService = new PatientService(patientRepository, patientAccountRepository); var specialtyRepository = new SpecialtySqlRepository(GetContextFactory()); var specialtyService = new SpecialtyService(specialtyRepository); // Auth var userAccountRepository = new UserAccountSqlRepository(GetContextFactory()); var credentialService = new CredentialsService(userAccountRepository, GetJwtSecretFromEnvironment()); // Advertisement var advertisementRepository = new AdvertisementSqlRepository(GetContextFactory()); var advertisementService = new AdvertisementService(advertisementRepository); services.Add(new ServiceDescriptor(typeof(CredentialsService), credentialService)); services.Add(new ServiceDescriptor(typeof(IPatientAccountService), patientAccountService)); services.Add(new ServiceDescriptor(typeof(IPatientRegistrationService), patientRegistrationService)); services.Add(new ServiceDescriptor(typeof(PatientService), patientService)); services.Add(new ServiceDescriptor(typeof(SpecialtyService), specialtyService)); services.Add(new ServiceDescriptor(typeof(AdvertisementService), advertisementService)); }