Ejemplo n.º 1
0
        public void Constructor_WhenGivenNullForResults_CoalescesToZeroResultsAndWarning()
        {
            var sut = new LayerResult("Layer A", new CheckResult[0]);

            Assert.That(sut.CheckResults, Is.Empty);
            Assert.That(sut.Level, Is.EqualTo(NotificationLevel.Warning), "Expected LayerResult to be a Warning if there was zero child CheckResults.");
        }
Ejemplo n.º 2
0
        public static Mock <ILayer> WithResult(this Mock <ILayer> layer, NotificationLevel level)
        {
            var name   = string.IsNullOrWhiteSpace(layer.Object.Name) ? "dummy-layer" : layer.Object.Name;
            var result = new LayerResult(name, new[] { new CheckResult("dummy-check-result", level) });

            layer.Setup(l => l.Run()).Returns(result);
            return(layer);
        }
Ejemplo n.º 3
0
        public void Constructor_WhenGivenMultipleCheckResults_AssumesWorstNotificationLevel()
        {
            var checkresults = new[]
            {
                new CheckResult("check 1", NotificationLevel.Okay),
                new CheckResult("check 2", NotificationLevel.Error), // Dead in the middle is the "worst" result
                new CheckResult("check 3", NotificationLevel.Okay),
            };

            var sut = new LayerResult("layer A", checkresults);

            Assert.That(sut.Level, Is.EqualTo(NotificationLevel.Error));
        }
Ejemplo n.º 4
0
        public void RenderPlainText_WhenChecksHaveErrors_IncludesMessages()
        {
            var checkresults = new[]
            {
                new CheckResult("check-a", NotificationLevel.Error, "custom message abc"),
                new CheckResult("check-b", NotificationLevel.Critical, "custom message xyz"),
            };

            var sut = new LayerResult("layer A", checkresults);

            var result = sut.RenderPlainText(NotificationLevel.Error);

            Assert.That(result.ToLowerInvariant(), Does.Contain("abc"));
            Assert.That(result.ToLowerInvariant(), Does.Contain("xyz"));
        }
Ejemplo n.º 5
0
        public void RenderPlainText_WhenResultIsMeaningFul_CombinesAllParts()
        {
            var checkresults = new[]
            {
                new CheckResult("check i", NotificationLevel.Okay),
                new CheckResult("check ii", NotificationLevel.Error),
            };

            var sut = new LayerResult("layer A", checkresults);

            var result = sut.RenderPlainText(NotificationLevel.Error);

            Assert.That(result, Does.Contain("layer A"));
            Assert.That(result, Does.Contain("Error"));
            Assert.That(result, Does.Contain("2"), "Expected number of child CheckResults to be in ToString value.");
        }
Ejemplo n.º 6
0
        public void RenderPlainText_WhenAskingForWarnings_IncludesWarningMessages()
        {
            var checkresults = new[]
            {
                new CheckResult("check-a", NotificationLevel.Okay, "Everything is Okay"),
                new CheckResult("check-a", NotificationLevel.Warning, "Everything is Warning"),
                new CheckResult("check-a", NotificationLevel.Error, "Everything is Error"),
                new CheckResult("check-b", NotificationLevel.Critical, "Everything is Critical"),
            };

            var sut = new LayerResult("layer A", checkresults);

            var result = sut.RenderPlainText(NotificationLevel.Warning);

            Assert.That(result, Does.Contain("Everything is Warning"));
            Assert.That(result, Does.Contain("Everything is Error"));
            Assert.That(result, Does.Contain("Everything is Critical"));
        }
Ejemplo n.º 7
0
        public void CheckLayers_WhenCalled_ReturnsListOfLayerResults()
        {
            var layerResult1 = new LayerResult("layer 1", new CheckResult[0]);
            var layer1       = new Mock <ILayer>();

            layer1.Setup(l => l.Run()).Returns(layerResult1);

            var layerResult2 = new LayerResult("layer 2", new CheckResult[0]);
            var layer2       = new Mock <ILayer>();

            layer2.Setup(l => l.Run()).Returns(layerResult2);

            var nimator = new NimatorEngine(new[] { layer1.Object, layer2.Object });
            var result  = nimator.RunSafe();

            Assert.That(result.LayerResults[0], Is.EqualTo(layerResult1));
            Assert.That(result.LayerResults[1], Is.EqualTo(layerResult2));
        }
Ejemplo n.º 8
0
        public void RenderPlainText_WhenChecksHaveErrors_IncludesCheckNames()
        {
            var checkresults = new[]
            {
                new CheckResult("check a", NotificationLevel.Okay),
                new CheckResult("check b", NotificationLevel.Warning),
                new CheckResult("check c", NotificationLevel.Error),
                new CheckResult("check d", NotificationLevel.Error),
                new CheckResult("check e", NotificationLevel.Critical),
            };

            var sut = new LayerResult("layer A", checkresults);

            var result = sut.RenderPlainText(NotificationLevel.Error);

            Assert.That(result.ToLowerInvariant(), Does.Not.Contain("check a"));
            Assert.That(result.ToLowerInvariant(), Does.Not.Contain("check b"));
            Assert.That(result.ToLowerInvariant(), Does.Contain("check c"));
            Assert.That(result.ToLowerInvariant(), Does.Contain("check d"));
            Assert.That(result.ToLowerInvariant(), Does.Contain("check e"));
        }