コード例 #1
0
        public void SetUp()
        {
            var fixture = new Fixture();

            _ukprn         = fixture.Create <long>();
            _uln           = fixture.Create <long>();
            _academicYear1 = fixture.Create <short>();
            _academicYear2 = fixture.Create <short>();

            _dataLockEventAy1 = fixture.Create <DataLockEventModel>();
            _dataLockEventAy2 = fixture.Create <DataLockEventModel>();

            _dataLockEventPayablePeriodAy1 = fixture.Create <DataLockEventPayablePeriodModel>();
            _dataLockEventPayablePeriodAy2 = fixture.Create <DataLockEventPayablePeriodModel>();
            _dataLockEventPriceEpisodeAy1  = fixture.Create <DataLockEventPriceEpisodeModel>();
            _dataLockEventPriceEpisodeAy2  = fixture.Create <DataLockEventPriceEpisodeModel>();

            var bsContextOption = new DbContextOptionsBuilder <MatchedLearnerDataContext>()
                                  .UseInMemoryDatabase($"TestDb-{Guid.NewGuid()}", new InMemoryDatabaseRoot())
                                  .Options;

            _dataDataContext = new MatchedLearnerDataContext(bsContextOption);

            var matchLearnerContextFactory = new MatchedLearnerDataContextFactory(bsContextOption);

            _sut = new MatchedLearnerRepository(_dataDataContext, matchLearnerContextFactory, fixture.Create <Mock <ILogger <MatchedLearnerRepository> > >().Object);
        }
        public void SetUp()
        {
            var fixture = new Fixture();

            fixture.Behaviors
            .OfType <ThrowingRecursionBehavior>()
            .ToList()
            .ForEach(b => fixture.Behaviors.Remove(b));
            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            _ukprn = fixture.Create <long>();
            _uln   = fixture.Create <long>();

            _dataLockEvent = fixture.Create <DataLockEventModel>();

            _dataLockEventNonPayablePeriod = fixture.Freeze <DataLockEventNonPayablePeriodModel>();
            _dataLockEventPayablePeriod    = fixture.Freeze <DataLockEventPayablePeriodModel>();
            _dataLockEventPriceEpisode     = fixture.Freeze <DataLockEventPriceEpisodeModel>();
            _dataLockEventPriceEpisode.PriceEpisodeIdentifier = Guid.NewGuid().ToString();

            var dbOptions = new DbContextOptionsBuilder <MatchedLearnerDataContext>()
                            .UseInMemoryDatabase($"TestDb-{Guid.NewGuid()}", new InMemoryDatabaseRoot())
                            .Options;

            _dataDataContext = new MatchedLearnerDataContext(dbOptions);

            var contextFactory = new MatchedLearnerDataContextFactory(dbOptions);

            _sut = new MatchedLearnerRepository(_dataDataContext, contextFactory, fixture.Create <Mock <ILogger <MatchedLearnerRepository> > >().Object);
        }
コード例 #3
0
        public TestRepository()
        {
            var applicationSettings = TestConfiguration.TestApplicationSettings;

            if (string.IsNullOrWhiteSpace(applicationSettings.MatchedLearnerConnectionString))
            {
                throw new InvalidOperationException("MatchedLearnerAcceptanceTestConnectionString is null");
            }

            var matchedLearnerOptions = new DbContextOptionsBuilder()
                                        .UseSqlServer(applicationSettings.MatchedLearnerConnectionString)
                                        .Options;

            _matchedLearnerDataContext = new MatchedLearnerDataContext(matchedLearnerOptions);

            if (string.IsNullOrWhiteSpace(applicationSettings.PaymentsConnectionString))
            {
                throw new InvalidOperationException("PaymentsAcceptanceTestConnectionString is null");
            }

            var paymentsOptions = new DbContextOptionsBuilder()
                                  .UseSqlServer(applicationSettings.PaymentsConnectionString)
                                  .Options;

            _paymentsDataContext = new PaymentsDataContext(paymentsOptions);
        }
コード例 #4
0
 public MatchedLearnerRepository(MatchedLearnerDataContext dataContext, IMatchedLearnerDataContextFactory matchedLearnerDataContextFactory, ILogger <MatchedLearnerRepository> logger)
 {
     _dataContext             = dataContext ?? throw new ArgumentNullException(nameof(dataContext));
     _retryDataContextFactory = matchedLearnerDataContextFactory ?? throw new ArgumentNullException(nameof(matchedLearnerDataContextFactory));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }