Skip to content

Commit 43d791b

Browse files
committed
Use C# 10 (default version for .NET 6) in the test project
Also use file-scoped namespaces
1 parent 1ed9743 commit 43d791b

6 files changed

+638
-644
lines changed

tests/CustomLogEventPropertyValue.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
using System.IO;
33
using Serilog.Events;
44

5-
namespace Serilog.Formatting.Log4Net.Tests
5+
namespace Serilog.Formatting.Log4Net.Tests;
6+
7+
internal class CustomLogEventPropertyValue : LogEventPropertyValue
68
{
7-
internal class CustomLogEventPropertyValue : LogEventPropertyValue
8-
{
9-
private readonly string _renderedText;
9+
private readonly string _renderedText;
1010

11-
public CustomLogEventPropertyValue(string renderedText)
12-
{
13-
_renderedText = renderedText;
14-
}
11+
public CustomLogEventPropertyValue(string renderedText)
12+
{
13+
_renderedText = renderedText;
14+
}
1515

16-
public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null)
17-
{
18-
output.Write(_renderedText);
19-
}
16+
public override void Render(TextWriter output, string? format = null, IFormatProvider? formatProvider = null)
17+
{
18+
output.Write(_renderedText);
2019
}
2120
}

tests/IndentationSettingsTest.cs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,46 @@
22
using FluentAssertions;
33
using Xunit;
44

5-
namespace Serilog.Formatting.Log4Net.Tests
5+
namespace Serilog.Formatting.Log4Net.Tests;
6+
7+
public class IndentationSettingsTest
68
{
7-
public class IndentationSettingsTest
9+
[Theory]
10+
[InlineData(Indentation.Space, 2, " ")]
11+
[InlineData(Indentation.Tab, 2, "\t\t")]
12+
[InlineData(Indentation.Space, 4, " ")]
13+
[InlineData(Indentation.Tab, 4, "\t\t\t\t")]
14+
public void IndentationSettingsToString(Indentation indentation, byte size, string expectedString)
15+
{
16+
// Arrange
17+
var indentationSettings = new IndentationSettings(indentation, size);
18+
19+
// Act
20+
var indentationString = indentationSettings.ToString();
21+
22+
// Assert
23+
indentationString.Should().Be(expectedString);
24+
}
25+
26+
[Fact]
27+
public void InvalidIndentation()
828
{
9-
[Theory]
10-
[InlineData(Indentation.Space, 2, " ")]
11-
[InlineData(Indentation.Tab, 2, "\t\t")]
12-
[InlineData(Indentation.Space, 4, " ")]
13-
[InlineData(Indentation.Tab, 4, "\t\t\t\t")]
14-
public void IndentationSettingsToString(Indentation indentation, byte size, string expectedString)
15-
{
16-
// Arrange
17-
var indentationSettings = new IndentationSettings(indentation, size);
18-
19-
// Act
20-
var indentationString = indentationSettings.ToString();
21-
22-
// Assert
23-
indentationString.Should().Be(expectedString);
24-
}
25-
26-
[Fact]
27-
public void InvalidIndentation()
28-
{
29-
// Act
30-
Func<IndentationSettings> action = () => new IndentationSettings((Indentation)(-1), size: 1);
31-
32-
// Assert
33-
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
34-
.Which.Message.Should().StartWith("The value of argument 'indentation' (-1) is invalid for enum type 'Indentation'.");
35-
}
36-
37-
[Fact]
38-
public void InvalidSize()
39-
{
40-
// Act
41-
Func<IndentationSettings> action = () => new IndentationSettings(indentation: default, size: 0);
42-
43-
// Assert
44-
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
45-
.Which.Message.Should().StartWith("The value of argument 'size' must be greater than 0.");
46-
}
29+
// Act
30+
var action = () => new IndentationSettings((Indentation)(-1), size: 1);
31+
32+
// Assert
33+
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
34+
.Which.Message.Should().StartWith("The value of argument 'indentation' (-1) is invalid for enum type 'Indentation'.");
35+
}
36+
37+
[Fact]
38+
public void InvalidSize()
39+
{
40+
// Act
41+
var action = () => new IndentationSettings(indentation: default, size: 0);
42+
43+
// Assert
44+
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
45+
.Which.Message.Should().StartWith("The value of argument 'size' must be greater than 0.");
4746
}
4847
}

tests/LineEndingTest.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
using FluentAssertions;
33
using Xunit;
44

5-
namespace Serilog.Formatting.Log4Net.Tests
5+
namespace Serilog.Formatting.Log4Net.Tests;
6+
7+
public class LineEndingTest
68
{
7-
public class LineEndingTest
9+
[Fact]
10+
public void InvalidLineEnding()
811
{
9-
[Fact]
10-
public void InvalidLineEnding()
11-
{
12-
Action action = () => _ = new Log4NetTextFormatter(c => c.UseLineEnding((LineEnding)4));
12+
Action action = () => _ = new Log4NetTextFormatter(c => c.UseLineEnding((LineEnding)4));
1313

14-
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
15-
.WithMessage("The value of argument 'lineEnding' (4) is invalid for enum type 'LineEnding'.*");
16-
}
14+
action.Should().ThrowExactly<ArgumentOutOfRangeException>()
15+
.WithMessage("The value of argument 'lineEnding' (4) is invalid for enum type 'LineEnding'.*");
1716
}
1817
}

0 commit comments

Comments
 (0)