public void SetupFixture()
 {
     _healthService    = Substitute.For <IHealthService>();
     _logger           = Substitute.For <ILogger <ExceptionCaptureMiddleware> >();
     _dummyDataFixture = new BasicDataFixture();
     _testServer       = new TestServerFixture(BuildTestRegistry());
 }
 public void SetupFixture()
 {
     _loggerFactory = Substitute.For <ILoggerFactory>();
     _requestLogger = Substitute.For <ILogger>();
     _loggerFactory.CreateLogger("RequestLogger").Returns(_requestLogger);
     _healthService    = Substitute.For <IHealthService>();
     _dummyDataFixture = new BasicDataFixture();
     _testServer       = new TestServerFixture(
         BuildTestRegistry(),
         s => s.Remove(s.Single(d => d.ServiceType == typeof(ILoggerFactory))));
 }
예제 #3
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();
        }
예제 #4
0
        public void Health_ShouldReturnSuccessMessage_WhenDatabaseAvailable()
        {
            // Arrange/Act
            _basicDataFixture = new BasicDataFixture();
            _testServer       = new TestServerFixture(BuildTestRegistryForSuccess());

            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.");

            _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);
        }