public async Task HealthCheckUtilityResult_ToDto_ConvertsProperly()
        {
            //Arrange
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();
            var healthCheckUtility         = new HealthCheckUtility(TestHelper.CreateHealthCheck(), healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Act
            var healthCheckUtilityResult = await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false);

            var getHealthCheckResponseDto = healthCheckUtilityResult.ToDto();

            //Assert
            Assert.AreEqual(getHealthCheckResponseDto.Status, HealthStatus.Active);
            Assert.AreEqual(HealthStatus.Active, getHealthCheckResponseDto.Status);
            Assert.AreEqual(getHealthCheckResponseDto.HealthChecks.Count, 3);

            var resultHealthCheck1 = getHealthCheckResponseDto.HealthChecks.SingleOrDefault(x => x.Description == "Test Health Check 1");

            Assert.IsNotNull(resultHealthCheck1);
            Assert.AreEqual(HealthStatus.Active, resultHealthCheck1.Status);
            Assert.AreEqual(resultHealthCheck1.Vitals.Count, 2);

            var resultHealthCheck1Vital1 = resultHealthCheck1.Vitals.SingleOrDefault(x => x.Description == "Health Check 1 Vital 1");

            Assert.IsNotNull(resultHealthCheck1Vital1);
            Assert.AreEqual(HealthStatus.Active, resultHealthCheck1Vital1.Status);
        }
        public async Task HealthCheckUtility_GetHealthCheckResult_ReturnsCriticalReport_WhenAtLeastOneVitalIsCritical()
        {
            //Arrange
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();
            var healthCheckUtility         = new HealthCheckUtility(TestHelper.CreateHealthCheck(HealthStatus.Critical), healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Act
            var healthCheckResult = await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false);

            //Assert
            Assert.AreEqual(HealthStatus.Critical, healthCheckResult.Status);
            Assert.AreEqual(healthCheckResult.Message, $"One or more system components have a status of {HealthStatus.Critical}.");
        }
示例#3
0
        public async Task FileUtility_HealthCheck_FileVaultBehaviors()
        {
            //Arrange
            var fileUtility = TestHelper.GetFileVaultFileUtility();
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();

            //Act
            var healthCheckUtility = new HealthCheckUtility(new List <IHealthCheckable>()
            {
                fileUtility
            }, healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Assert
            Assert.AreEqual(HealthStatus.Active, (await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false)).Status);
        }
        public async Task JwtUtility_HealthCheck_FncConnectBehaviors()
        {
            //Arrange
            var fncConnectGenerateJwtBehavior = new FncConnectGenerateJwtBehavior(new HttpUtility(), TestHelper.GetConfigurationSettings());
            var fncConnectValidateJwtBehavior = new FncConnectValidateJwtBehavior(new HttpUtility(), TestHelper.GetConfigurationSettings());
            var jwtUtility = new JwtUtility(fncConnectValidateJwtBehavior, fncConnectGenerateJwtBehavior);
            var healthcheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();

            //Act
            var healthCheckUtility = new HealthCheckUtility(new List <IHealthCheckable>()
            {
                jwtUtility
            }, healthcheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Assert
            Assert.AreEqual(HealthStatus.Active, (await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false)).Status);
        }
示例#5
0
        public async Task LdapUtility_HealthCheck_Behaviors()
        {
            //Arrange
            var coreLogicToAuthBehavior    = new CoreLogicConnectToAuthLdapBehavior(TestHelper.GetConfigurationSettings());
            var fncConnectToLdapBehavior   = new FncConnectToGroupLdapBehavior(TestHelper.GetConfigurationSettings());
            var getLdapGroupsBehavior      = new GetLdapGroupsBehavior();
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();

            var ldapUtility = new LdapUtility(coreLogicToAuthBehavior, fncConnectToLdapBehavior, getLdapGroupsBehavior);

            //Act
            var healthCheckUtility = new HealthCheckUtility(new List <IHealthCheckable>()
            {
                ldapUtility
            }, healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Assert
            Assert.AreEqual((await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false)).Status, HealthStatus.Active);
        }
        public async Task HealthCheckController_GetHealthCheck_ReturnsActiveReport()
        {
            //Arrange
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();
            var healthCheckUtility         = new HealthCheckUtility(TestHelper.CreateHealthCheck(), healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());
            var healthCheckController      = new HealthCheckController(healthCheckUtility);

            //Act
            var result = await healthCheckController.Get().ConfigureAwait(false);

            //Assert
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));

            var okObjectResult = (OkObjectResult)result;

            Assert.IsInstanceOfType(okObjectResult.Value, typeof(GetHealthCheckResponseDto));

            var healthCheckResponseDto = (GetHealthCheckResponseDto)okObjectResult.Value;

            Assert.AreEqual(healthCheckResponseDto.Status, HealthStatus.Active);
        }
        public async Task HealthCheckUtility_GetHealthCheckResult_ReturnsActiveReport_WhenAllVitalsAreActive()
        {
            //Arrange
            var healthCheckNotifierUtility = new Mock <IHealthCheckNotifierUtility>();
            var healthCheckUtility         = new HealthCheckUtility(TestHelper.CreateHealthCheck(), healthCheckNotifierUtility.Object, TestHelper.GetConfigurationSettings());

            //Act
            var healthCheckResult = await healthCheckUtility.GetHealthCheckResultAsync().ConfigureAwait(false);

            //Assert
            Assert.AreEqual(HealthStatus.Active, healthCheckResult.Status);
            Assert.AreEqual(3, healthCheckResult.HealthChecks.Count);

            var resultHealthCheck1 = healthCheckResult.HealthChecks.SingleOrDefault(x => x.Description == "Test Health Check 1");

            Assert.IsNotNull(resultHealthCheck1);
            Assert.AreEqual(HealthStatus.Active, resultHealthCheck1.Status);
            Assert.AreEqual(2, resultHealthCheck1.Vitals.Count);

            var resultHealthCheck1Vital1 = resultHealthCheck1.Vitals.SingleOrDefault(x => x.Description == "Health Check 1 Vital 1");

            Assert.IsNotNull(resultHealthCheck1Vital1);
            Assert.AreEqual(HealthStatus.Active, resultHealthCheck1Vital1.Status);
        }