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)); }
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; }
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)); }
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)); }
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(); }
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; })); }
public PaymentDataRepository(Lazy <EmployerIncentivesDbContext> context) { _dbContext = context.Value; }
public AccountDataRepository(Lazy <EmployerIncentivesDbContext> dbContext) { _dbContext = dbContext.Value; }
public UlnValidationService(Lazy <EmployerIncentivesDbContext> context) { _context = context.Value; }