示例#1
0
        public async Task CheckAsync_WhenCheckPasses_ReturnsHealthyResult()
        {
            // arrange
            var connectionFactory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            _log.Setup(_ => _.Log(LogLevel.Error, It.IsAny <Func <string> >(), It.IsAny <Exception>(), It.IsAny <object[]>()))
            .Returns(true);

            var healthCheck = new RabbitMQHealthCheck("test", connectionFactory, _log.Object);

            // act
            var result = await healthCheck.ExecuteAsync().ConfigureAwait(false);

            // assert
            result.Should().NotBeNull()
            .And.Subject.As <HealthCheck.Result>().Check.Status.Should().Be(HealthCheckStatus.Healthy);
        }
示例#2
0
        public async Task CheckAsync_WhenFaultyConnectionDetails_ReturnsUnHealthyResult()
        {
            // arrange
            var connectionFactory = new ConnectionFactory()
            {
                HostName = "localhost",
                Port     = 5673 // wrong
            };

            _log.Setup(_ => _.Log(LogLevel.Error, It.IsAny <Func <string> >(), It.IsAny <BrokerUnreachableException>(), It.IsAny <object[]>()))
            .Returns(true)
            .Verifiable();

            var healthCheck = new RabbitMQHealthCheck("test", connectionFactory, _log.Object);

            // act
            var result = await healthCheck.ExecuteAsync().ConfigureAwait(false);

            // assert
            result.Should().NotBeNull()
            .And.Subject.As <HealthCheck.Result>().Check.Status.Should().Be(HealthCheckStatus.Unhealthy);
            _log.Verify();
        }