예제 #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         TestServerFixture.Dispose();
     }
 }
        public void Health_ShouldReturnSuccessMessage_WhenDatabaseAvailable()
        {
            // Arrange/Act
            _testServer = new TestServerFixture();

            var response = _testServer.Client.GetAsync(@"/health").Result;
            var body     = response.Content.ReadAsStringAsync().Result;

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            body.Should().Contain("The API is working correctly.");

            _testServer.Dispose();
        }
예제 #3
0
        public void Background()
        {
            "Given a running auth server".x(() => _fixture = new TestServerFixture(_outputHelper, BaseUrl))
            .Teardown(() => _fixture?.Dispose());

            "And the server signing keys".x(
                async() =>
            {
                var keysJson = await _fixture.Client().GetStringAsync(BaseUrl + "/jwks").ConfigureAwait(false);
                var keys     = JsonConvert.DeserializeObject <JsonWebKeySet>(keysJson);

                _jwks = keys !;
                Assert.NotEmpty(_jwks?.Keys);
            });
        }
예제 #4
0
        public void Health_ShouldReturnFailureMessage_WhenDatabaseUnavailable()
        {
            // arrange
            // act
            _basicDataFixture = new BasicDataFixture();
            _testServer       = new TestServerFixture(BuildTestRegistryForFailure());

            var response = _testServer.Client.GetAsync(@"/health").Result;
            var body     = response.Content.ReadAsStringAsync().Result;

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            body.Should().Contain("One or more components of the API are malfunctioning.");

            _basicDataFixture.Dispose();
            _testServer.Dispose();
        }
        public string ValidPrimeNumber(int number)
        {
            // Arrange/Act
            _basicDataFixture = new BasicDataFixture();
            _testServer       = new TestServerFixture(BuildTestRegistryForSuccess());

            var response = _testServer.Client.GetAsync(string.Format("/primefactor?number={0}", number)).Result;
            var body     = response.Content.ReadAsStringAsync().Result;

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);

            _basicDataFixture.Dispose();
            _testServer.Dispose();

            return(body);
        }
예제 #6
0
        public void Background()
        {
            "Given loaded configuration values".x(
                () =>
            {
                var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json", false, false)
                                    .Build();
                ConnectionString = configuration["Db:ConnectionString"];
                OutputHelper.WriteLine(ConnectionString);
                Assert.NotNull(ConnectionString);
            });

            "Given a configured database".x(
                async() =>
            {
                ConnectionString = await DbInitializer.Init(
                    OutputHelper,
                    ConnectionString,
                    DefaultStores.Consents(),
                    DefaultStores.Users(),
                    DefaultStores.Clients(SharedContext.Instance),
                    DefaultStores.Scopes())
                                   .ConfigureAwait(false);
                var builder = new NpgsqlConnectionStringBuilder(ConnectionString);

                Assert.False(string.IsNullOrWhiteSpace(builder.SearchPath));
                OutputHelper.WriteLine(ConnectionString);
            })
            .Teardown(async() => { await DbInitializer.Drop(ConnectionString, OutputHelper).ConfigureAwait(false); });

            "and a running auth server"
            .x(() => Fixture = new TestServerFixture(OutputHelper, ConnectionString, BaseUrl))
            .Teardown(() => Fixture.Dispose());

            "And the server signing keys".x(
                async() =>
            {
                var keysJson = await Fixture.Client().GetStringAsync(BaseUrl + "/jwks").ConfigureAwait(false);
                Jwks         = new JsonWebKeySet(keysJson);

                Assert.NotEmpty(Jwks.Keys);
            });
        }
예제 #7
0
        public void Background()
        {
            "Given loaded configuration values".x(
                () =>
            {
                var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json", false, false).Build();
                _connectionString = configuration["Db:ConnectionString"];
                Assert.NotNull(_connectionString);
            });

            "Given a configured database".x(
                async() =>
            {
                _connectionString = await DbInitializer.Init(
                    _output,
                    _connectionString,
                    DefaultStores.Consents(),
                    DefaultStores.Users(),
                    DefaultStores.Clients(SharedContext.Instance),
                    DefaultStores.Scopes())
                                    .ConfigureAwait(false);
            })
            .Teardown(async() => { await DbInitializer.Drop(_connectionString).ConfigureAwait(false); });

            "and a running auth server".x(() => _fixture = new TestServerFixture(_output, _connectionString, BaseUrl))
            .Teardown(() => _fixture.Dispose());

            "And the server signing keys".x(
                async() =>
            {
                var keysJson = await _fixture.Client().GetStringAsync(BaseUrl + "/jwks").ConfigureAwait(false);
                _jwks        = new JsonWebKeySet(keysJson);

                Assert.NotEmpty(_jwks.Keys);
            });
        }
예제 #8
0
 public void Teardown()
 {
     _testServer.Dispose();
 }
 public void TearDown()
 {
     _testServerFixture.Dispose();
 }
 public void OneTimeTearDown()
 {
     _testServer.Dispose();
     _dummyDataFixture.Dispose();
 }
예제 #11
0
 public void Dispose()
 {
     _server?.Dispose();
     _server = null;
 }
 public void Dispose()
 {
     TestServerFixture.Dispose();
 }
 public void TearDownFixture()
 {
     _customersDataFixture.Dispose();
     _testServer.Dispose();
 }