示例#1
0
        public async Task GetCounterSummariesForAuditCountsNoDataAndInProgressAsNoData()
        {
            // Arrange
            var randomizer = new Random();

            await using var context = JosekiTestsDb.CreateUniqueContext();
            var wrapper = new InfraScoreDbWrapper(context);

            var auditId = randomizer.Next();
            await context.CheckResult.AddRangeAsync(new[]
            {
                new CheckResultEntity {
                    AuditId = auditId, Value = CheckValue.NoData, Check = new CheckEntity {
                        Severity = CheckSeverity.Critical
                    }
                },
                new CheckResultEntity {
                    AuditId = auditId, Value = CheckValue.InProgress, Check = new CheckEntity {
                        Severity = CheckSeverity.High
                    }
                },
            });

            await context.SaveChangesAsync();

            // Act
            var summary = await wrapper.GetCounterSummariesForAudit(auditId);

            // Assert
            summary.Failed.Should().Be(0);
            summary.Warning.Should().Be(0);
            summary.NoData.Should().Be(2);
            summary.Passed.Should().Be(0);
        }
示例#2
0
        public async Task GetCounterSummariesForAuditReturnsZeroSummaryForNotExistingId()
        {
            // Arrange
            var randomizer = new Random();

            await using var context = JosekiTestsDb.CreateUniqueContext();
            var wrapper = new InfraScoreDbWrapper(context);

            var auditId = randomizer.Next();
            await context.CheckResult.AddRangeAsync(new[]
            {
                new CheckResultEntity {
                    AuditId = auditId - 1, Value = CheckValue.Succeeded, Check = new CheckEntity {
                        Severity = CheckSeverity.Critical
                    }
                },
                new CheckResultEntity {
                    AuditId = auditId + 1, Value = CheckValue.Succeeded, Check = new CheckEntity {
                        Severity = CheckSeverity.Critical
                    }
                },
            });

            await context.SaveChangesAsync();

            // Act
            var summary = await wrapper.GetCounterSummariesForAudit(auditId);

            // Assert
            summary.Failed.Should().Be(0);
            summary.Warning.Should().Be(0);
            summary.NoData.Should().Be(0);
            summary.Passed.Should().Be(0);
        }
示例#3
0
        public async Task GetCounterSummariesForAuditCountsAllNotCriticalAndHighSeverityIssuesAsWarnings()
        {
            // Arrange
            var randomizer = new Random();

            await using var context = JosekiTestsDb.CreateUniqueContext();
            var wrapper = new InfraScoreDbWrapper(context);

            var auditId = randomizer.Next();
            await context.CheckResult.AddRangeAsync(new[]
            {
                new CheckResultEntity {
                    AuditId = auditId, Value = CheckValue.Failed, Check = new CheckEntity {
                        Severity = CheckSeverity.Medium
                    }
                },
                new CheckResultEntity {
                    AuditId = auditId, Value = CheckValue.Failed, Check = new CheckEntity {
                        Severity = CheckSeverity.Low
                    }
                },
                new CheckResultEntity {
                    AuditId = auditId, Value = CheckValue.Failed, Check = new CheckEntity {
                        Severity = CheckSeverity.Unknown
                    }
                },
            });

            await context.SaveChangesAsync();

            // Act
            var summary = await wrapper.GetCounterSummariesForAudit(auditId);

            // Assert
            summary.Failed.Should().Be(0);
            summary.Warning.Should().Be(3);
            summary.NoData.Should().Be(0);
            summary.Passed.Should().Be(0);
        }