Skip to content

Commit d50f34b

Browse files
committed
Remove unnecessary casts in Log4NetTextFormatterOptionsTest
1 parent 849268d commit d50f34b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/Log4NetTextFormatterOptionsTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Reflection;
44
using System.Xml;
55
using FluentAssertions;
6-
using Serilog.Events;
76
using Xunit;
87

98
namespace Serilog.Formatting.Log4Net.Tests
@@ -14,8 +13,8 @@ namespace Serilog.Formatting.Log4Net.Tests
1413
public class Log4NetTextFormatterOptionsTest
1514
{
1615
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 => "";
1918

2019
[Fact]
2120
public void NullXmlWriterSettings_ThrowsArgumentNullException()
@@ -25,7 +24,7 @@ public void NullXmlWriterSettings_ThrowsArgumentNullException()
2524
const CDataMode cDataMode = default;
2625
XmlQualifiedName? log4NetXmlNamespace = default;
2726
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};
2928

3029
// Act
3130
Action action = () => Log4NetTextFormatterOptionsConstructor.Invoke(parameters);
@@ -45,7 +44,7 @@ public void NullPropertyFilter_ThrowsArgumentNullException()
4544
XmlQualifiedName? log4NetXmlNamespace = default;
4645
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
4746
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};
4948

5049
// Act
5150
Action action = () => Log4NetTextFormatterOptionsConstructor.Invoke(parameters);
@@ -65,7 +64,7 @@ public void NullExceptionFormatter_ThrowsArgumentNullException()
6564
XmlQualifiedName? log4NetXmlNamespace = default;
6665
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
6766
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};
6968

7069
// Act
7170
Action action = () => Log4NetTextFormatterOptionsConstructor.Invoke(parameters);

0 commit comments

Comments
 (0)