Exemple #1
0
        public void LogFilterPositive()
        {
            LogRow    row    = LogRow.GetInstance(this.readOnlyColumns);
            LogColumn column = this.readOnlyColumns[0];

            MemoryStream memoryStream = new MemoryStream();
            LogFilter    filter       = LogFilter.GetTestInstance(
                delegate { return(LogWriter.GetInstance(memoryStream, false)); },
                column.Parameter,
                column.Conversion);

            LogFilter.SetDefaultBehavior(true);

            filter.LogStart(row);
            filter.LogEntry(row);
            filter.LogEntry(row);
            filter.LogStop();

            string actual   = Encoding.ASCII.GetString(memoryStream.ToArray());
            string expected =
                "Parameter1, Parameter2, Parameter3" + Environment.NewLine +
                "0, 0.0, 0.00" + Environment.NewLine +
                "0, 0.0, 0.00" + Environment.NewLine;

            Assert.AreEqual(expected, actual, "Log with two entries");
        }
Exemple #2
0
        public void LogFilterTwoLogs()
        {
            int          iteration     = 1;
            MemoryStream memoryStream1 = new MemoryStream();
            MemoryStream memoryStream2 = new MemoryStream();

            LogRow    row    = LogRow.GetInstance(this.readOnlyColumns);
            LogColumn column = this.readOnlyColumns[0];
            LogFilter filter = LogFilter.GetTestInstance(
                delegate
            {
                if (iteration == 1)
                {
                    return(LogWriter.GetInstance(memoryStream1, false));
                }
                else
                {
                    return(LogWriter.GetInstance(memoryStream2, false));
                }
            },
                column.Parameter,
                column.Conversion);

            LogFilter.SetDefaultBehavior(true);

            filter.LogStart(row);
            filter.LogEntry(row);
            filter.LogEntry(row);
            filter.LogStop();
            iteration = 2;
            filter.LogStart(row);
            filter.LogEntry(row);
            filter.LogEntry(row);
            filter.LogStop();

            string actual   = Encoding.ASCII.GetString(memoryStream1.ToArray());
            string expected =
                "Parameter1, Parameter2, Parameter3" + Environment.NewLine +
                "0, 0.0, 0.00" + Environment.NewLine +
                "0, 0.0, 0.00" + Environment.NewLine;

            Assert.AreEqual(expected, actual, "first log");

            actual = Encoding.ASCII.GetString(memoryStream2.ToArray());
            Assert.AreEqual(expected, actual, "second log");
        }