public void Render_Always_StartsWithNow(int maxLogSize, int lineCount) { var testContext = new TestContext() { MaxLogSize = maxLogSize }; testContext.AddExistingLines(lineCount); var result = testContext.Uut.Render(); result.ShouldStartWith(testContext.Now.ToString(Logger.DateTimeFormat)); }
public void Clear_Always_ClearsLines(int maxLogSize, int lineCount) { var testContext = new TestContext() { MaxLogSize = maxLogSize }; testContext.AddExistingLines(lineCount); testContext.Uut.Clear(); testContext.Uut.LogLines.ShouldBeEmpty(); }
public void Render_Always_IncludesAllCurrentLinesOrderedByAge(int maxLogSize, int lineCount) { var testContext = new TestContext() { MaxLogSize = maxLogSize }; var existingLines = testContext.AddExistingLines(lineCount); var result = testContext.Uut.Render(); result.ShouldContain(string.Join("\n", existingLines .Reverse() .Take(maxLogSize))); }
public void AddLine_MaxLogSizeIsGreaterThan0_AddsLineToFrontAndRemovesLinesFromBackIfNeeded(int maxLogSize, int lineCount, string line) { var testContext = new TestContext() { MaxLogSize = maxLogSize }; var existingLines = testContext.AddExistingLines(lineCount); testContext.Uut.AddLine(line); testContext.Uut.LogLines.ShouldBe( existingLines .Reverse() .Prepend(line) .Take(maxLogSize), ignoreOrder: false); }