Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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)));
        }
Ejemplo n.º 4
0
        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);
        }