コード例 #1
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_ClassAndMethod_Success()
        {
            // Fake Data
            var fakeClassName   = "Foo";
            var fakeMethodName  = "Bar";
            var fakeFileName    = "FooBar.exe";
            var fakeLineNumber  = "42";
            var fakeLoggingData = new LoggingEventData()
            {
                LocationInfo = new LocationInfo(fakeClassName, fakeMethodName, fakeFileName, fakeLineNumber)
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var classResult  = underTest.GetFieldValue("class", fakeLoggingEvent);
            var methodResult = underTest.GetFieldValue("method", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeClassName, classResult);
            CollectionAssert.AreEqual(fakeMethodName, methodResult);
        }
コード例 #2
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_UnknownProperty_Success()
        {
            // Fake Data
            var fakePropertyName = "Panic";
            var fakeLoggingData  = new LoggingEventData();
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue(fakePropertyName, fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(string.Empty, result);
        }
コード例 #3
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_AppDomain_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                Domain = "Homer"
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("appdomain", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeLoggingData.Domain, result);
        }
コード例 #4
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_UserName_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                UserName = "******"
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("username", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeLoggingData.UserName, result);
        }
コード例 #5
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_Thread_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                ThreadName = "OriginalBob"
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("thread", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeLoggingData.ThreadName, result);
        }
コード例 #6
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_Identity_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                Identity = "Bob"
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("identity", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeLoggingData.Identity, result);
        }
コード例 #7
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_Exception_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                ExceptionString = new Exception("Don't Panic!").ToString()
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("exception", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakeLoggingData.ExceptionString, result);
        }
コード例 #8
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_Level_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                Level = Level.Error
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("level", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(Level.Error.DisplayName, result);
        }
コード例 #9
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_Message_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                Message = "The answer",
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("message", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual("The answer", result);
        }
コード例 #10
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_NullProperty_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                Message = null
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("message", fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(string.Empty, result);
        }
コード例 #11
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_CustomProperty_Success()
        {
            // Fake Data
            var fakePropertyName  = "Towels";
            var fakePropertyValue = "Of Course";
            var fakeLoggingData   = new LoggingEventData()
            {
                Properties = new PropertiesDictionary()
            };

            fakeLoggingData.Properties[fakePropertyName] = fakePropertyValue;
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue(fakePropertyName, fakeLoggingEvent);

            // Verify Results
            CollectionAssert.AreEqual(fakePropertyValue, result);
        }
コード例 #12
0
ファイル: CsvLayoutTests.cs プロジェクト: bablov/log4net.Csv
        public void CsvLayout_GetFieldValue_BuiltInProperties_UtcDate_Success()
        {
            // Fake Data
            var fakeLoggingData = new LoggingEventData()
            {
                TimeStampUtc = new DateTime(2012, 12, 14, 12, 20, 42)
            };
            var fakeLoggingEvent = new LoggingEvent(fakeLoggingData);

            // Execute Test
            var underTest = new CsvLayout();

            underTest.ActivateOptions();
            var result = underTest.GetFieldValue("utcdate", fakeLoggingEvent);

            // Verify Results
            var isoDateFormatter = new Iso8601DateFormatter();
            var stringWriter     = new StringWriter(new StringBuilder());

            isoDateFormatter.FormatDate(fakeLoggingData.TimeStampUtc, stringWriter);
            var expectedDateString = stringWriter.GetStringBuilder().ToString();

            CollectionAssert.AreEqual(expectedDateString, result);
        }