public ServiceProvider BuildServices() { var services = new ServiceCollection(); var baseUrl = "http://localhost:5000/"; var configSettings = new Dictionary <string, string>() { { common.Constants.API_URL_CONFIG_KEY, baseUrl }, { Constants.API.API_URL_CONFIG_KEY, baseUrl }, { Integrations.Api.ProxyClient.Client.Constants.API_URL_CONFIG_KEY, baseUrl }, }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(configSettings) .Build(); // Set up default services services.AddScoped <IConfiguration>(c => configuration); services.AddIocMapping(); services.AddAutoMapper(AutoMapperSetup.Config); services.AddHttpClients(configuration); services.AddSharedServices(); var userContext = new StaticUserContext(new UserContext { UserId = 81730 }); services.AddSingleton <ICurrentUserContext>(userContext); _integrationService = A.Fake <IIntegrationService>(); _uniMicroClient = A.Fake <IUnimicroClient>(); _unitService = A.Fake <IUnitService>(); _entityMapService = A.Fake <IEntityMapService>(); _unitQueries = A.Fake <IUnitQueries>(); var absenceTypeService = A.Fake <IAbsenceTypeService>(); var fakeEmployeeService = A.Fake <IEmployeeService>(); var fakeAuthorizationContext = A.Fake <IAuthorizationContextService>(); services.ReplaceScoped <IUnitQueries>(_unitQueries); services.ReplaceScoped <IUnimicroClient>(_uniMicroClient); services.ReplaceScoped <IEntityMapService>(_entityMapService); services.ReplaceScoped <IUnitService>(_unitService); services.ReplaceScoped <IEmployeeService>(fakeEmployeeService); services.ReplaceScoped <IAbsenceTypeService>(absenceTypeService); services.ReplaceScoped <IAuthorizationContextService>(fakeAuthorizationContext); services.ReplaceSingleton(_integrationService); services.ReplaceScoped <IDbContextFactory <TimeregDbContext>, InMemoryDbContextFactory>(); services.AddScoped <IConsumer <IAbsenceApproved>, AbsenceApprovedConsumer>(); services.AddScoped <IConsumer <IAbsenceDeleted>, AbsenceDeletedConsumer>(); services.AddScoped <IConsumer <IIntegrationDeleted>, IntegrationDeleteConsumer>(); services.AddScoped <IConsumer <IEmployeeDeleted>, EmployeeDeletedConsumer>(); return(services.BuildServiceProvider()); }
public UniMicroAdapter( IMapper mapper, IUnimicroClient unimicroClient, IUnitService unitService, IEntityMapService entityMapService) { _mapper = mapper; _unimicroClient = unimicroClient; _unitService = unitService; _entityMapService = entityMapService; }
public async Task SetUp() { var configSettings = new Dictionary <string, string>(); configSettings.Add(Constants.API.API_PASSWORD_CONFIG_KEY, "Sticos-integration"); IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false, true) .Build(); var serviceCollection = new ServiceCollection(); serviceCollection.AddIocMapping(); serviceCollection.AddHttpClient <IUnimicroClient, UnimicroClient>(); serviceCollection.AddScoped <IConfiguration>(c => config); _provider = serviceCollection.BuildServiceProvider(); _proxy = _provider.GetService <IUnimicroClient>(); var result = _proxy.SignIn().Result; var company = _proxy.GetAndSetCompanyAuthorizationInfo(_legalOrganizationNumber).Result; }
public async Task SetUp() { var settings = new Dictionary <string, string>(); settings.Add("Unimicro.Api.Url", "http://dummyUrl"); settings.Add("Common_Api_Url", "http://dummyUrl"); settings.Add("Integrations_Api_Url", "http://dummyUrl"); _actions = (sc) => { _unitService = A.Fake <IUnitService>(); _employeeService = A.Fake <commonContracts.IEmployeeService>(); _absenceTypeService = A.Fake <IAbsenceTypeService>(); _unimicroClient = A.Fake <IUnimicroClient>(); A.CallTo(() => _unimicroClient.SignIn()).Returns(new Login { AccessToken = "accessToken" }); sc.ReplaceTransient <IDbContextFactory <TimeregDbContext>, InMemoryDbContextFactory>(); sc.ReplaceScoped <IUnitService>(_unitService); sc.ReplaceScoped <commonContracts.IEmployeeService>(_employeeService); sc.ReplaceScoped <IAbsenceTypeService>(_absenceTypeService); sc.ReplaceScoped <IUnimicroClient>(_unimicroClient); }; _testServer = new TestServerBuilder() .WithPostConfigureCollection(_actions) .WithConfigSettings(settings) .Build <Startup>(); _client = _testServer.CreateClientWithJwtToken(CustomerId, _userId); _mapper = _testServer.Host.Services.GetService <IMapper>(); var dbFactory = _testServer.Host.Services.GetService <IDbContextFactory <TimeregDbContext> >(); _db = await dbFactory.CreateDbContext(); }
public UniMicroExternalDataService(IUnitService unitService, IUnimicroClient unimicroClient) { _unitService = unitService; _unimicroClient = unimicroClient; Logger = NullLogger <UniMicroExternalDataService> .Instance; }