public void CreateDataSet()
        {
            var options = new DbContextOptionsBuilder <DigNDB_SmittestopContext>()
                          .UseInMemoryDatabase(nameof(EuGatewayServiceUploadTest))
                          .Options;

            _dbContext = new DigNDB_SmittestopContext(options);
            _dbContext.Database.EnsureDeleted();

            _config = new EuGatewayConfig()
            {
                AuthenticationCertificateFingerprint = "AuthenticationCertificateFingerprint",
                SigningCertificateFingerprint        = "SigningCertificateFingerprint",
                Url = "http://netcompany.pl",
            };

            _denmark = TestCountryBuilder.Denmark.Build();
            _poland  = TestCountryBuilder.Poland.Build();
            _germany = TestCountryBuilder.Germany.Build();
            _latvia  = TestCountryBuilder.Latvia.Build();

            _dbContext.AddRange(new Country[] { _denmark, _poland, _germany, _latvia });
            _dbContext.SaveChanges();

            _originCountry = _denmark;
        }
Beispiel #2
0
        public void CreateDataSet()
        {
            var options = new DbContextOptionsBuilder <DigNDB_SmittestopContext>()
                          .UseInMemoryDatabase(nameof(EuGatewayServiceUploadTest))
                          .Options;

            _dbContext = new DigNDB_SmittestopContext(options);
            _dbContext.Database.EnsureDeleted();

            _temporaryExposureKeyRepositoryLogger = new Mock <ILogger <TemporaryExposureKeyRepository> >(MockBehavior.Loose);
            _loggerGatewayWebContextReader        = new Mock <ILogger <GatewayWebContextReader> >();
            var translationsRepositoryMock = new Mock <IGenericRepository <Translation> >(MockBehavior.Strict);

            _countryRepository = new CountryRepository(_dbContext, translationsRepositoryMock.Object, new AppSettingsConfig());
            _autoMapper        = CreateAutoMapperWithDependencies(_countryRepository);

            _config = new EuGatewayConfig()
            {
                AuthenticationCertificateFingerprint = "AuthenticationCertificateFingerprint",
                SigningCertificateFingerprint        = "SigningCertificateFingerprint",
                Url = "http://netcompany.pl",
            };

            _epochConverter = new EpochConverter();

            _denmark = TestCountryBuilder.Denmark.Build();
            _poland  = TestCountryBuilder.Poland.Build();
            _germany = TestCountryBuilder.Germany.Build();
            _latviaDisabledDownload = TestCountryBuilder.Latvia
                                      .SetIsPullingFromGatewayEnabled(false)
                                      .Build();

            _dbContext.AddRange(_denmark, _poland, _germany, _latviaDisabledDownload);
            _dbContext.SaveChanges();
        }
Beispiel #3
0
        private DigNDB_SmittestopContext CreatePopulatedContext <T>(IEnumerable <T> entities)
            where T : class
        {
            var context = new DigNDB_SmittestopContext(_options);

            context.Database.EnsureDeleted();
            context.AddRange(entities);
            context.SaveChanges();

            return(context);
        }
Beispiel #4
0
        public void SetUp()
        {
            GenerateData();
            DbContextOptions <DigNDB_SmittestopContext> options =
                new DbContextOptionsBuilder <DigNDB_SmittestopContext>()
                .UseInMemoryDatabase(nameof(ApplicationStatisticsRepositoryTests)).Options;

            _context = new DigNDB_SmittestopContext(options);
            _context.Database.EnsureDeleted();
            _context.AddRange(_covidStatisticsMockData);
            _context.SaveChanges();
        }
        private CountryRepository CreateCountryRepository(Country[] fakeCountries)
        {
            DbContextOptions <DigNDB_SmittestopContext> options =
                new DbContextOptionsBuilder <DigNDB_SmittestopContext>()
                .UseInMemoryDatabase(nameof(CountryRepositoryTests)).Options;
            var context = new DigNDB_SmittestopContext(options);

            context.Database.EnsureDeleted();

            fakeCountries[0].Code = ExampleCountryCodePl;
            fakeCountries[1].Code = ExampleCountryCodeDk;

            var exposureKeyCountries = new List <TemporaryExposureKeyCountry>
            {
                new TemporaryExposureKeyCountry
                {
                    CountryId = 1
                },
                new TemporaryExposureKeyCountry
                {
                    CountryId = 2
                },
            };

            context.AddRange(fakeCountries);
            context.AddRange(exposureKeyCountries);
            context.SaveChanges();

            var translationRepositoryMock = new Mock <IGenericRepository <Translation> >();

            IOriginSpecificSettings config = new AppSettingsConfig()
            {
                OriginCountryCode = ExampleCountryCodeDk
            };

            return(new CountryRepository(context, translationRepositoryMock.Object, config));
        }
Beispiel #6
0
        public async Task GetNewestEntryAsync_EntriesExist_ShouldReturnNewestEntry()
        {
            // Arrange
            _context.AddRange(_appStatisticsMockData);
            _context.SaveChanges();
            var applicationStatisticsRepository = CreateApplicationStatisticsRepository();

            // Act
            var result = await applicationStatisticsRepository.GetNewestEntryAsync();

            // Assert
            var expected = _appStatisticsMockData[1];

            Assert.AreEqual(expected.EntryDate, result.EntryDate);
            Assert.AreEqual(expected.Id, result.Id);
            Assert.AreEqual(expected.PositiveResultsLast7Days, result.PositiveResultsLast7Days);
            Assert.AreEqual(expected.PositiveTestsResultsTotal, result.PositiveTestsResultsTotal);
            Assert.AreEqual(expected.SmittestopDownloadsTotal, result.SmittestopDownloadsTotal);
        }