コード例 #1
0
        public async Task CheckHealthAsync_Unhealthy_ThrowException()
        {
            var check = new RedisCheck();

            var settings = new RedisCheckSettings("redis", false, 0, null, "instance");
            var context  = new HealthCheckContext(settings);

            var database = new Mock <IDatabase>();

            database
            .Setup(d => d.PingAsync(It.IsAny <CommandFlags>()))
            .ThrowsAsync(new Exception());
            settings.Database = database.Object;

            await Assert.ThrowsAsync <Exception>(async() => await check.CheckHealthAsync(context, settings));
        }
コード例 #2
0
        public async Task CheckHealthAsync_Healthy_CheckSucceeded()
        {
            var check = new RedisCheck();

            var settings = new RedisCheckSettings("redis", false, 0, null, "instance");
            var context  = new HealthCheckContext(settings);
            var database = new Mock <IDatabase>();

            database
            .Setup(d => d.PingAsync(It.IsAny <CommandFlags>()))
            .ReturnsAsync(TimeSpan.Zero);
            settings.Database = database.Object;

            await check.CheckHealthAsync(context, settings);

            Assert.True(context.HasSucceeded);
        }