public void RenderPlainText_ForThreshold_AsksLayerResultsToRenderForThreshold() { var layerResultMock = new Mock <ILayerResult>(); var sut = new NimatorResult(DateTime.Now); sut.LayerResults.Add(layerResultMock.Object); Assert.That(sut.RenderPlainText(NotificationLevel.Warning), Is.Not.Empty); layerResultMock.Verify(l => l.RenderPlainText(NotificationLevel.Warning), Times.Once); }
public void RenderPlainText_WhenNoResultsAvailable_ReturnsSaneText() { var sut = new NimatorResult(DateTime.Now); sut.LayerResults.Clear(); var result = sut.RenderPlainText(NotificationLevel.Error); Assert.That(result, Is.Not.Null.And.Not.Empty); }
public void RenderPlainText_ForInterestingResults_RendersSensibleText() { // This is a smoke test. We want to be able to iterate fast on the // exact formatting, without having to fix fragile tests all the // time (so this test has only "fuzzy" checks). var timestamp = new DateTime(2016, 8, 22, 13, 45, 0); var sut = new NimatorResult(timestamp) { Finished = timestamp.AddSeconds(5) }; sut.LayerResults.Add(new LayerResult("layer-1", new[] { new CheckResult("check-a", NotificationLevel.Okay), new CheckResult("check-b", NotificationLevel.Warning), })); sut.LayerResults.Add(new LayerResult("layer-2", new[] { new CheckResult("check-q", NotificationLevel.Okay), new CheckResult("check-w", NotificationLevel.Error), new CheckResult("check-e", NotificationLevel.Error), })); sut.LayerResults.Add(new LayerResult("layer-3", new[] { new CheckResult("check-x", NotificationLevel.Okay), new CheckResult("check-y", NotificationLevel.Okay), new CheckResult("check-z", NotificationLevel.Critical), })); // Case insensitivity by lowering the result before the assertions. var result = sut.RenderPlainText(NotificationLevel.Error).ToLowerInvariant(); var firstLine = result.Substring(0, result.IndexOf("\n", StringComparison.Ordinal)); Assert.That(firstLine, Does.Contain("2016-08-22")); Assert.That(firstLine, Does.Contain("13:45:00")); Assert.That(firstLine, Does.Contain("13:45:05")); Assert.That(firstLine, Does.Contain("critical")); Assert.That(result, Does.Contain("layer-1")); Assert.That(result, Does.Contain("layer-2")); Assert.That(result, Does.Contain("layer-3")); }