public void Setup()
        {
            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>().UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _dbContext = new EmployerIncentivesDbContext(options);
            _sut       = new ApprenticeshipIncentives.ApprenticeshipIncentiveDataRepository(new Lazy <EmployerIncentivesDbContext>(_dbContext));
        }
コード例 #2
0
        public async Task Setup()
        {
            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>().UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _dbContext = new EmployerIncentivesDbContext(options);
            _sut       = new ApprenticeshipIncentives.ApprenticeshipIncentiveDataRepository(new Lazy <EmployerIncentivesDbContext>(_dbContext));
            await AddCollectionCalendarPeriod();
        }
 public ApprenticeApplicationDataRepository(
     Lazy <EmployerIncentivesDbContext> dbContext,
     IDateTimeService dateTimeService,
     ICollectionCalendarService collectionCalendarService)
 {
     _dbContext                 = dbContext.Value;
     _dateTimeService           = dateTimeService;
     _collectionCalendarService = collectionCalendarService;
 }
コード例 #4
0
        public void Arrange()
        {
            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);

            _sut = new IncentiveApplicationApprenticeshipQueryRepository(new Lazy <EmployerIncentivesDbContext>(_context));
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);
            _sut     = new ApprenticeshipIncentives.PaymentsQueryRepository(new Lazy <EmployerIncentivesDbContext>(_context));
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _dbContext = new EmployerIncentivesDbContext(options);

            _sut = new Data.AccountDataRepository(new Lazy <EmployerIncentivesDbContext>(_dbContext));
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);

            _sut = new IncentiveApplicationLegalEntity.IncentiveApplicationLegalEntityQueryRepository(new Lazy <EmployerIncentivesDbContext>(_context));
        }
コード例 #8
0
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);

            _sut = new Data.UlnValidationService(new Lazy <EmployerIncentivesDbContext>(_context));
        }
コード例 #9
0
        public void Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _context = new EmployerIncentivesDbContext(options);

            _mockDateTimeService           = new Mock <IDateTimeService>();
            _mockCollectionCalendarService = new Mock <ICollectionCalendarService>();

            _sut = new Data.ApprenticeApplicationDataRepository(new Lazy <EmployerIncentivesDbContext>(_context), _mockDateTimeService.Object, _mockCollectionCalendarService.Object);
        }
        public async Task Arrange()
        {
            _fixture = new Fixture();
            _uln     = _fixture.Create <long>();
            _accountLegalEntityId = _fixture.Create <long>();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _dbContext = new EmployerIncentivesDbContext(options);

            _sut = new ApprenticeshipIncentives.ApprenticeshipIncentiveDataRepository(new Lazy <EmployerIncentivesDbContext>(_dbContext));
            await AddApprenticeshipIncentiveModel(_accountLegalEntityId, _uln);
            await AddApprenticeshipIncentiveModel(_accountLegalEntityId, _uln + 1);
            await AddApprenticeshipIncentiveModel(_accountLegalEntityId + 1, _uln);
        }
        public async Task Arrange()
        {
            _fixture = new Fixture();

            var options = new DbContextOptionsBuilder <EmployerIncentivesDbContext>()
                          .UseInMemoryDatabase("EmployerIncentivesDbContext" + Guid.NewGuid()).Options;

            _dbContext = new EmployerIncentivesDbContext(options);

            _testApplication = _fixture
                               .Build <IncentiveApplicationModel>()
                               .Create();

            _sut = new IncentiveApplication.IncentiveApplicationDataRepository(new Lazy <EmployerIncentivesDbContext>(_dbContext));
            await _sut.Add(_testApplication);

            await _dbContext.SaveChangesAsync();
        }
コード例 #12
0
        public static IServiceCollection AddEntityFrameworkForEmployerIncentives(this IServiceCollection services)
        {
            return(services.AddScoped(p =>
            {
                var unitOfWorkContext = p.GetService <IUnitOfWorkContext>();
                EmployerIncentivesDbContext dbContext;
                try
                {
                    var synchronizedStorageSession = unitOfWorkContext.Get <SynchronizedStorageSession>();
                    var sqlStorageSession = synchronizedStorageSession.GetSqlStorageSession();
                    var optionsBuilder = new DbContextOptionsBuilder <EmployerIncentivesDbContext>().UseSqlServer(sqlStorageSession.Connection);
                    dbContext = new EmployerIncentivesDbContext(optionsBuilder.Options);
                    dbContext.Database.UseTransaction(sqlStorageSession.Transaction);
                }
                catch (KeyNotFoundException)
                {
                    var settings = p.GetService <IOptions <ApplicationSettings> >();
                    var optionsBuilder = new DbContextOptionsBuilder <EmployerIncentivesDbContext>().UseSqlServer(settings.Value.DbConnectionString);
                    dbContext = new EmployerIncentivesDbContext(optionsBuilder.Options);
                }

                return dbContext;
            }));
        }
コード例 #13
0
 public PaymentDataRepository(Lazy <EmployerIncentivesDbContext> context)
 {
     _dbContext = context.Value;
 }
コード例 #14
0
 public AccountDataRepository(Lazy <EmployerIncentivesDbContext> dbContext)
 {
     _dbContext = dbContext.Value;
 }
コード例 #15
0
 public UlnValidationService(Lazy <EmployerIncentivesDbContext> context)
 {
     _context = context.Value;
 }