예제 #1
0
        public void Setup()
        {
            FlatFileSinkData sinkParams = new FlatFileSinkData();

            sinkParams.FileName = CommonUtil.FileName;
            sinkParams.Header   = "";
            sinkParams.Footer   = "";
            this.sink           = new FlatFileSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));
            CommonUtil.ResetEventLogCounter();
        }
예제 #2
0
        public void LogMessageToFlatFileWithNullFileName()
        {
            FlatFileSinkData sinkParams = new FlatFileSinkData();
            sinkParams.FileName = null;

            this.sink = new FlatFileSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(this.sink);

            Assert.AreEqual(1, CommonUtil.EventLogEntryCount(), "confirm warning written to event log");
            string entry = CommonUtil.GetLastEventLogEntry();
            string expected = SR.DefaultLogDestinationMessage + Environment.NewLine + Environment.NewLine +
                SR.FileSinkMissingConfiguration;
            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm error message");
        }
예제 #3
0
        public void MissingRequiredParameters()
        {
            // create a flatfile sink without the required parameters
            FlatFileSink badSink = new FlatFileSink();

            badSink.Initialize(new TestLogSinkConfigurationView(new FlatFileSinkData()));
            CommonUtil.SendTestMessage(badSink);
            Assert.AreEqual(1, CommonUtil.EventLogEntryCount(), "confirm an error message was written to event log");

            string entry    = CommonUtil.GetLastEventLogEntry();
            string expected = SR.DefaultLogDestinationMessage + Environment.NewLine + Environment.NewLine +
                              SR.FileSinkMissingConfiguration;

            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm error message");

            expected = CommonUtil.FormattedMessage;
            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm message is inside");
        }
예제 #4
0
        public void LogMessageToFlatFileWithNullFileName()
        {
            FlatFileSinkData sinkParams = new FlatFileSinkData();

            sinkParams.FileName = null;

            this.sink = new FlatFileSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(this.sink);

            Assert.AreEqual(1, CommonUtil.EventLogEntryCount(), "confirm warning written to event log");
            string entry    = CommonUtil.GetLastEventLogEntry();
            string expected = SR.DefaultLogDestinationMessage + Environment.NewLine + Environment.NewLine +
                              SR.FileSinkMissingConfiguration;

            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm error message");
        }
예제 #5
0
        public void LogMessageToFlatFileWithNoPath()
        {
            string fileName = "trace.log";
            FlatFileSinkData sinkParams = new FlatFileSinkData();
            sinkParams.FileName = fileName;
            sinkParams.Header = "";
            sinkParams.Footer = "";

            this.sink = new FlatFileSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(this.sink);

            FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(stream);
            string contents = reader.ReadToEnd();
            stream.Close();

            Assert.AreEqual(0, CommonUtil.EventLogEntryCount(), "confirm no messages written to event log");
            Assert.IsTrue(contents.IndexOf(CommonUtil.FormattedMessage) > -1, "confirm message is part of contents");
        }
예제 #6
0
        public void LogMessageToFlatFileWithNullHeaderFooter()
        {
            string           fileName   = "trace.log";
            FlatFileSinkData sinkParams = new FlatFileSinkData();

            sinkParams.FileName = fileName;
            sinkParams.Header   = null;
            sinkParams.Footer   = null;

            this.sink = new FlatFileSink();
            sink.Initialize(new TestLogSinkConfigurationView(sinkParams));

            CommonUtil.SendTestMessage(this.sink);

            FileStream   stream   = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            StreamReader reader   = new StreamReader(stream);
            string       contents = reader.ReadToEnd();

            stream.Close();

            Assert.AreEqual(0, CommonUtil.EventLogEntryCount(), "confirm no messages written to event log");
            Assert.IsTrue(contents.IndexOf(CommonUtil.FormattedMessage) > -1, "confirm message is part of contents");
        }
예제 #7
0
 public void Setup()
 {
     FlatFileSinkData sinkParams = new FlatFileSinkData();
     sinkParams.FileName = CommonUtil.FileName;
     sinkParams.Header = "";
     sinkParams.Footer = "";
     this.sink = new FlatFileSink();
     sink.Initialize(new TestLogSinkConfigurationView(sinkParams));
     CommonUtil.ResetEventLogCounter();
 }
예제 #8
0
        public void MissingRequiredParameters()
        {
            // create a flatfile sink without the required parameters
            FlatFileSink badSink = new FlatFileSink();
            badSink.Initialize(new TestLogSinkConfigurationView(new FlatFileSinkData()));
            CommonUtil.SendTestMessage(badSink);
            Assert.AreEqual(1, CommonUtil.EventLogEntryCount(), "confirm an error message was written to event log");

            string entry = CommonUtil.GetLastEventLogEntry();
            string expected = SR.DefaultLogDestinationMessage + Environment.NewLine + Environment.NewLine +
                SR.FileSinkMissingConfiguration;
            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm error message");

            expected = CommonUtil.FormattedMessage;
            Assert.IsTrue(entry.IndexOf(expected) > -1, "confirm message is inside");
        }