コード例 #1
0
        public async Task CheckHealthAsync_Warning_CheckWarned(long virtualMemorySize, long errorThreshold, long warningThreshold)
        {
            var virtualMemorySizeProvider = new TestVirtualMemorySizeProvider(virtualMemorySize);
            var check = new VirtualMemorySizeCheck(virtualMemorySizeProvider);

            var settings = new FloorThresholdCheckSettings("virtual memory size", false, 0, null, errorThreshold, warningThreshold);
            var context  = new HealthCheckContext(settings);

            await check.CheckHealthAsync(context, settings);

            Assert.True(context.HasWarned);
        }
コード例 #2
0
        public async Task CheckHealthAsync_Unhealthy_ThrowsException()
        {
            var virtualMemorySizeProvider = new Mock <IVirtualMemorySizeProvider>();

            virtualMemorySizeProvider
            .Setup(p => p.GetVirtualMemorySize())
            .Throws(new Exception());
            var check = new VirtualMemorySizeCheck(virtualMemorySizeProvider.Object);

            var settings = new FloorThresholdCheckSettings("virtual memory size", false, 0, null, 0, 0);
            var context  = new HealthCheckContext(settings);

            await Assert.ThrowsAsync <Exception>(async() => await check.CheckHealthAsync(context, settings));
        }