public CertificateGroupTestFixture()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            _configuration = builder.Build();
            _configuration.Bind("OpcVault", _serviceConfig);
            _configuration.Bind("Auth", _clientConfig);
            if (!InvalidConfiguration())
            {
                RandomGenerator = new ApplicationTestDataGenerator();

                var timeid = (DateTime.UtcNow.ToFileTimeUtc() / 1000) % 10000;
                GroupId  = "GroupTestIssuerCA" + timeid.ToString();
                ConfigId = "GroupTestConfig" + timeid.ToString();
                var keyVaultServiceClient = KeyVaultServiceClient.Get(ConfigId, _serviceConfig, _clientConfig, _logger);
                KeyVault = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                KeyVault.PurgeAsync(ConfigId, GroupId).Wait();
                KeyVault.CreateCertificateGroupConfiguration(GroupId, "CN=OPC Vault Cert Request Test CA, O=Microsoft, OU=Azure IoT", null).Wait();
            }
            KeyVaultInitOk = false;
        }
        public ApplicationDatabaseTestFixture()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            _configuration = builder.Build();
            _configuration.Bind("OpcVault", _serviceConfig);
            _configuration.Bind("Auth", _clientConfig);
            _logger = SerilogTestLogger.Create <ApplicationDatabaseTestFixture>();
            if (!InvalidConfiguration())
            {
                RandomGenerator       = new ApplicationTestDataGenerator(_randomStart);
                _documentDBRepository = new OpcVaultDocumentDbRepository(_serviceConfig);
                ApplicationsDatabase  = CosmosDBApplicationsDatabaseFactory.Create(null, _serviceConfig, _documentDBRepository, _logger);
                // create test set
                ApplicationTestSet = new List <ApplicationTestData>();
                for (int i = 0; i < _testSetSize; i++)
                {
                    var randomApp = RandomGenerator.RandomApplicationTestData();
                    ApplicationTestSet.Add(randomApp);
                }
                // try initialize DB
                ApplicationsDatabase.Initialize().Wait();
            }
            RegistrationOk = false;
        }
        public CertificateRequestTestFixture()
        {
            RandomGenerator = new ApplicationTestDataGenerator(_randomStart);
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();
            IConfigurationRoot configuration = builder.Build();

            configuration.Bind("OpcVault", _serviceConfig);
            configuration.Bind("Auth", _clientConfig);
            _logger = SerilogTestLogger.Create <CertificateRequestTestFixture>();
            if (!InvalidConfiguration())
            {
                _documentDBRepository = new OpcVaultDocumentDbRepository(_serviceConfig);
                ApplicationsDatabase  = CosmosDBApplicationsDatabaseFactory.Create(null, _serviceConfig, _documentDBRepository, _logger);

                var timeid = (DateTime.UtcNow.ToFileTimeUtc() / 1000) % 10000;
                _groupId  = "CertReqIssuerCA" + timeid.ToString();
                _configId = "CertReqConfig" + timeid.ToString();
                var keyVaultServiceClient = KeyVaultServiceClient.Get(_configId, _serviceConfig, _clientConfig, _logger);
                _keyVaultCertificateGroup = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                _keyVaultCertificateGroup.PurgeAsync(_configId, _groupId).Wait();
                CertificateGroup = _keyVaultCertificateGroup;
                CertificateGroup = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                CertificateGroup.CreateCertificateGroupConfiguration(_groupId, "CN=OPC Vault Cert Request Test CA, O=Microsoft, OU=Azure IoT", null).Wait();
                CertificateRequest = CosmosDBCertificateRequestFactory.Create(ApplicationsDatabase, CertificateGroup, _serviceConfig, _documentDBRepository, _logger);

                // create test set
                ApplicationTestSet = new List <ApplicationTestData>();
                for (int i = 0; i < _testSetSize; i++)
                {
                    var randomApp = RandomGenerator.RandomApplicationTestData();
                    ApplicationTestSet.Add(randomApp);
                }
                // try initialize DB
                ApplicationsDatabase.Initialize().Wait();
            }
            RegistrationOk = false;
        }