コード例 #1
0
        public async Task <AbsenceExport> GetAbsenceExport(string id)
        {
            _db = await GetContext();

            var absenceExport       = _db.AbsenceExports.FirstOrDefault(x => x.Id == id);
            var absenceExportMapped = _mapper.Map <AbsenceExport>(absenceExport);

            return(absenceExportMapped);
        }
コード例 #2
0
        public UniMicroTestSetup()
        {
            _services  = BuildServices();
            _dbFactory = _services.GetService <IDbContextFactory <TimeregDbContext> >();

            // Poor mans database-reset
            _dbFactory.CreateDbContext().Result.Database.EnsureDeleted();

            _db     = _dbFactory.CreateDbContext().Result;
            _mapper = _services.GetService <IMapper>();
            _externalWorkItemIds        = 1;
            _externalEmploymentLeaveIds = 101;
        }
コード例 #3
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>();
                _unitService        = A.Fake <IUnitService>();
                _entitymapService   = A.Fake <IEntityMapService>();
                _unitQueries        = A.Fake <IUnitQueries>();

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

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

            _client = _testServer.CreateClientWithJwtToken(_customerId, _userId);

            var dbFactory = _testServer.Host.Services.GetService <IDbContextFactory <TimeregDbContext> >();

            _mapper = _testServer.Host.Services.GetService <IMapper>();
            _db     = await dbFactory.CreateDbContext();
        }
コード例 #4
0
        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();
        }