public void FormatMessage_ReturnsExpectedString()
        {
            TraceFilter filter = new TestTraceFilter("WebJob failures detected.");

            for (int i = 0; i < 10; i++)
            {
                filter.Filter(new TraceEvent(TraceLevel.Error, string.Format("Event {0}", i), null, new Exception("Kaboom!")));
            }

            // verify message formatting taking less than the total number of events
            string message = filter.GetDetailedMessage(3);

            string[] messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.Equal(8, messageLines.Length);
            Assert.Equal("WebJob failures detected.", messageLines[0]);
            Assert.Equal(string.Empty, messageLines[1].Trim());
            Assert.True(messageLines[2].EndsWith("Error Event 9  System.Exception: Kaboom!"));
            Assert.Equal(string.Empty, messageLines[3].Trim());
            Assert.True(messageLines[4].EndsWith("Error Event 8  System.Exception: Kaboom!"));
            Assert.Equal(string.Empty, messageLines[5].Trim());
            Assert.True(messageLines[6].EndsWith("Error Event 7  System.Exception: Kaboom!"));

            // verify message formatting taking greater than the total number of events
            message      = filter.GetDetailedMessage(15);
            messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            Assert.Equal(11, messageLines.Length);

            // test with no events
            filter.Events.Clear();
            message      = filter.GetDetailedMessage(3);
            messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.Equal(2, messageLines.Length);
            Assert.Equal("WebJob failures detected.", messageLines[0]);
            Assert.Equal(string.Empty, messageLines[1].Trim());
        }
        public void FormatMessage_ReturnsExpectedString()
        {
            TraceFilter filter = new TestTraceFilter("WebJob failures detected.");

            for (int i = 0; i < 10; i++)
            {
                filter.Filter(new TraceEvent(TraceLevel.Error, string.Format("Event {0}", i), null, new Exception("Kaboom!")));
            }

            // verify message formatting taking less than the total number of events
            string message = filter.GetDetailedMessage(3);
            string[] messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.Equal(8, messageLines.Length);
            Assert.Equal("WebJob failures detected.", messageLines[0]);
            Assert.Equal(string.Empty, messageLines[1].Trim());
            Assert.True(messageLines[2].EndsWith("Error Event 9  System.Exception: Kaboom!"));
            Assert.Equal(string.Empty, messageLines[3].Trim());
            Assert.True(messageLines[4].EndsWith("Error Event 8  System.Exception: Kaboom!"));
            Assert.Equal(string.Empty, messageLines[5].Trim());
            Assert.True(messageLines[6].EndsWith("Error Event 7  System.Exception: Kaboom!"));

            // verify message formatting taking greater than the total number of events
            message = filter.GetDetailedMessage(15);
            messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            Assert.Equal(11, messageLines.Length);

            // test with no events
            filter.Events.Clear();
            message = filter.GetDetailedMessage(3);
            messageLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.Equal(2, messageLines.Length);
            Assert.Equal("WebJob failures detected.", messageLines[0]);
            Assert.Equal(string.Empty, messageLines[1].Trim());
        }