3
3
using System . Reflection ;
4
4
using System . Xml ;
5
5
using FluentAssertions ;
6
- using Serilog . Events ;
7
6
using Xunit ;
8
7
9
8
namespace Serilog . Formatting . Log4Net . Tests
@@ -14,8 +13,8 @@ namespace Serilog.Formatting.Log4Net.Tests
14
13
public class Log4NetTextFormatterOptionsTest
15
14
{
16
15
private static ConstructorInfo Log4NetTextFormatterOptionsConstructor { get ; } = typeof ( Log4NetTextFormatter ) . Assembly . GetType ( "Serilog.Formatting.Log4Net.Log4NetTextFormatterOptions" ) ! . GetConstructors ( BindingFlags . NonPublic | BindingFlags . Instance ) . Single ( ) ;
17
- private static bool FilterProperty ( LogEvent logEvent , string propertyName ) => true ;
18
- private static string FormatException ( Exception _ ) => "" ;
16
+ private static readonly PropertyFilter FilterProperty = ( logEvent , propertyName ) => true ;
17
+ private static readonly ExceptionFormatter FormatException = exception => "" ;
19
18
20
19
[ Fact ]
21
20
public void NullXmlWriterSettings_ThrowsArgumentNullException ( )
@@ -25,7 +24,7 @@ public void NullXmlWriterSettings_ThrowsArgumentNullException()
25
24
const CDataMode cDataMode = default ;
26
25
XmlQualifiedName ? log4NetXmlNamespace = default ;
27
26
XmlWriterSettings xmlWriterSettings = null ! ;
28
- var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , ( PropertyFilter ) FilterProperty , ( ExceptionFormatter ) FormatException } ;
27
+ var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , FilterProperty , FormatException } ;
29
28
30
29
// Act
31
30
Action action = ( ) => Log4NetTextFormatterOptionsConstructor . Invoke ( parameters ) ;
@@ -45,7 +44,7 @@ public void NullPropertyFilter_ThrowsArgumentNullException()
45
44
XmlQualifiedName ? log4NetXmlNamespace = default ;
46
45
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings ( ) ;
47
46
PropertyFilter filterProperty = null ! ;
48
- var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , filterProperty , ( ExceptionFormatter ) FormatException } ;
47
+ var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , filterProperty , FormatException } ;
49
48
50
49
// Act
51
50
Action action = ( ) => Log4NetTextFormatterOptionsConstructor . Invoke ( parameters ) ;
@@ -65,7 +64,7 @@ public void NullExceptionFormatter_ThrowsArgumentNullException()
65
64
XmlQualifiedName ? log4NetXmlNamespace = default ;
66
65
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings ( ) ;
67
66
ExceptionFormatter formatException = null ! ;
68
- var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , ( PropertyFilter ) FilterProperty , formatException } ;
67
+ var parameters = new object ? [ ] { formatProvider , cDataMode , log4NetXmlNamespace , xmlWriterSettings , FilterProperty , formatException } ;
69
68
70
69
// Act
71
70
Action action = ( ) => Log4NetTextFormatterOptionsConstructor . Invoke ( parameters ) ;
0 commit comments