public void SetupTest()
        {
            var appSettings = new AppSettings();
            var diskOptions = new DiskStorageOptions();

            DiskOptionsPercentageSetup.Setup(appSettings.TempFolder, diskOptions);

            var value = diskOptions.GetType().GetRuntimeFields().FirstOrDefault();

            Assert.IsNotNull(value);
        }
        public async Task RunFail_NullReferenceException()
        {
            var appSettings = new AppSettings();
            var diskOptions = new DiskStorageOptions();

            DiskOptionsPercentageSetup.Setup(appSettings.TempFolder, diskOptions, 99.9f);

            var healthCheck = new HealthCheckContext();

            await new DiskStorageHealthCheck(diskOptions).CheckHealthAsync(healthCheck);
        }
        public async Task RunSuccessful()
        {
            var appSettings = new AppSettings();
            var diskOptions = new DiskStorageOptions();

            DiskOptionsPercentageSetup.Setup(appSettings.TempFolder, diskOptions, 0.000001f);

            var healthCheck = new HealthCheckContext();
            var result      = await new DiskStorageHealthCheck(diskOptions).CheckHealthAsync(healthCheck);

            Assert.AreEqual(HealthStatus.Healthy, result.Status);
        }
        public async Task RunFailNotEnoughSpace()
        {
            var appSettings = new AppSettings();
            var diskOptions = new DiskStorageOptions();

            DiskOptionsPercentageSetup.Setup(appSettings.TempFolder, diskOptions, 1.01f);

            var healthCheck = new HealthCheckContext {
                Registration = new HealthCheckRegistration("te", new DiskStorageHealthCheck(diskOptions), null, null)
            };
            var result = await new DiskStorageHealthCheck(diskOptions).CheckHealthAsync(healthCheck);

            Assert.AreEqual(HealthStatus.Unhealthy, result.Status);
            Assert.IsTrue(result.Description.Contains("Minimum configured megabytes for disk"));
        }
示例#5
0
        public void CheckIfServiceExist()
        {
            var services = new ServiceCollection();

            services
            .AddHealthChecks()
            .AddDiskStorageHealthCheck(diskOptions => { DiskOptionsPercentageSetup.Setup(new CreateAnImage().BasePath, diskOptions); },
                                       name: "ThumbnailTempFolder");

            if (services.All(x => x.ServiceType != typeof(HealthCheckService)))
            {
                // Service doesn't exist, do something
                throw new ArgumentException("missing service");
            }
        }