コード例 #1
0
        public async Task SetUp()
        {
            var settings = new Dictionary <string, string>();

            settings.Add("Common_Api_Url", "http://localhost");
            settings.Add("Integrations_Api_Url", "http://localhost");
            settings.Add("Unimicro.Api.Url", "http://test-api.unieconomy.no/api/");
            settings.Add(Unimicro.Constants.Constants.API.API_USERNAME_CONFIG_KEY, "Sticos-integration");
            settings.Add(Unimicro.Constants.Constants.API.API_PASSWORD_CONFIG_KEY, "Sticosintegration123");

            _actions = (sc) =>
            {
                _integrationService = A.Fake <IIntegrationService>();
                _entitymapService   = A.Fake <IEntityMapService>();

                sc.ReplaceTransient <IDbContextFactory <TimeregDbContext>, InMemoryDbContextFactory>();
                sc.ReplaceScoped <IIntegrationService>(_integrationService);
                sc.ReplaceScoped <IEntityMapService>(_entitymapService);
            };

            _testServer = new TestServerBuilder()
                          .WithPostConfigureCollection(_actions)
                          .WithConfigSettings(settings)
                          .Build <Startup>();

            _client = _testServer.CreateClientWithJwtToken(_customerId, _userId);
            _mapper = _testServer.Host.Services.GetService <IMapper>();
        }
コード例 #2
0
        public static async Task <int?> GetExternalId(this IEntityMapService entityMapService,
                                                      EntityType entityType,
                                                      IdentifierEntity idEntity,
                                                      IdentifierProperty property,
                                                      int localId,
                                                      int unitId)
        {
            var entityMaps = await entityMapService.SearchEntityMaps(
                new SearchQueryEntityMap(
                    localId,
                    entityType.ToString(),
                    unitId,
                    (int)ExternalEconomySystem.UniMicro,
                    (int)Category.Timereg)
            {
                ExternalEntity   = idEntity.ToString(),
                ExternalProperty = property.ToString()
            });

            var value = entityMaps.FirstOrDefault()?.ExternalValue;

            return(int.TryParse(value, out int intValue) && intValue > 0
                ? (int?)intValue
                : null);
        }
コード例 #3
0
 public static async Task <int?> GetWorkerId(this IEntityMapService entityMapService, int localEmployeeId, int unitId)
 {
     return(await entityMapService.GetExternalId(
                EntityType.Employee,
                IdentifierEntity.Worker,
                IdentifierProperty.Id,
                localEmployeeId,
                unitId));
 }
コード例 #4
0
 public static async Task <int?> GetWorkTypeId(this IEntityMapService entityMapService, int localAbsenceCode, int unitId)
 {
     return(await entityMapService.GetExternalId(
                EntityType.AbsenceType,
                IdentifierEntity.WorkType,
                IdentifierProperty.Id,
                localAbsenceCode,
                unitId));
 }
コード例 #5
0
        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());
        }
コード例 #6
0
 public UniMicroAdapter(
     IMapper mapper,
     IUnimicroClient unimicroClient,
     IUnitService unitService,
     IEntityMapService entityMapService)
 {
     _mapper           = mapper;
     _unimicroClient   = unimicroClient;
     _unitService      = unitService;
     _entityMapService = entityMapService;
 }
コード例 #7
0
 public EmployeeDeletedConsumer(IEntityMapService entityMapService, IStaticCustomerId staticCustomerId)
 {
     _entityMapService = entityMapService;
     _staticCustomerId = staticCustomerId;
 }
コード例 #8
0
 public UnimicroValidator(IIntegrationService integrationService, IEntityMapService entityMapService)
 {
     _integrationService = integrationService;
     _entityMapService   = entityMapService;
 }
コード例 #9
0
 public EntityMapController(IEntityMapService entityMapService, IMapper mapper)
 {
     _entityMapService = entityMapService;
     _mapper           = mapper;
 }
コード例 #10
0
 public ExternalSystemValidatorFactory(IIntegrationService integrationService, IEntityMapService entityMapService)
 {
     _integrationService = integrationService;
     _entityMapService   = entityMapService;
 }