Skip to content

Commit

Permalink
Merge pull request #200 from apache/Feature/NUnitBump
Browse files Browse the repository at this point in the history
bumped NUnit to 4.2.2
  • Loading branch information
FreeAndNil authored Oct 22, 2024
2 parents 884dbf6 + 39ed3b3 commit b008475
Show file tree
Hide file tree
Showing 48 changed files with 872 additions and 960 deletions.
26 changes: 15 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ dotnet_naming_style.prefix_underscore.required_prefix = _

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 2
Expand All @@ -79,7 +79,7 @@ dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:none
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
Expand Down Expand Up @@ -121,7 +121,7 @@ csharp_space_around_binary_operators = before_and_after
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_prefer_range_operator = true:none
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
Expand Down Expand Up @@ -165,4 +165,8 @@ dotnet_diagnostic.KR1012.severity = none
# KR1013: Name base classes correctly
dotnet_diagnostic.KR1013.severity = none
# KR1037: Use EnvironmentHelper instead of DateTime.
dotnet_diagnostic.KR1037.severity = none
dotnet_diagnostic.KR1037.severity = none
# NUnit2045: Use Assert.Multiple
dotnet_diagnostic.NUnit2045.severity = none
# IDE0079: Remove unnecessary suppressions
dotnet_diagnostic.IDE0079.severity = none
9 changes: 5 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
<SystemConfigurationConfigurationManagerPackageVersion>4.5.0</SystemConfigurationConfigurationManagerPackageVersion>
<MicrosoftSourceLinkGitHubPackageVersion>8.0.0</MicrosoftSourceLinkGitHubPackageVersion>
<!-- Test Packages -->
<MicrosoftNetTestSdkPackageVersion>17.9.0</MicrosoftNetTestSdkPackageVersion>
<NUnitPackageVersion>3.14.0</NUnitPackageVersion>
<NUnit3TestAdapterPackageVersion>4.5.0</NUnit3TestAdapterPackageVersion>
<QuackersTestLoggerPackageVersion>1.0.24</QuackersTestLoggerPackageVersion>
<MicrosoftNetTestSdkPackageVersion>17.11.1</MicrosoftNetTestSdkPackageVersion>
<NUnitAnalyzersPackageVersion>4.3.0</NUnitAnalyzersPackageVersion>
<NUnitPackageVersion>4.2.2</NUnitPackageVersion>
<NUnit3TestAdapterPackageVersion>4.6.0</NUnit3TestAdapterPackageVersion>
<QuackersTestLoggerPackageVersion>1.0.25</QuackersTestLoggerPackageVersion>
</PropertyGroup>
</Project>
57 changes: 27 additions & 30 deletions src/log4net.Tests/Appender/AdoNetAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void NoBufferingTest()

ILog log = LogManager.GetLogger(rep.Name, "NoBufferingTest");
log.Debug("Message");
Assert.NotNull(Log4NetCommand.MostRecentInstance);
Assert.AreEqual(1, Log4NetCommand.MostRecentInstance!.ExecuteNonQueryCount);
Assert.That(Log4NetCommand.MostRecentInstance, Is.Not.Null);
Assert.That(Log4NetCommand.MostRecentInstance!.ExecuteNonQueryCount, Is.EqualTo(1));
}

[Test]
Expand All @@ -76,11 +76,11 @@ public void BufferingTest()
for (int i = 0; i < bufferSize; i++)
{
log.Debug("Message");
Assert.IsNull(Log4NetCommand.MostRecentInstance);
Assert.That(Log4NetCommand.MostRecentInstance, Is.Null);
}
log.Debug("Message");
Assert.NotNull(Log4NetCommand.MostRecentInstance);
Assert.AreEqual(bufferSize + 1, Log4NetCommand.MostRecentInstance!.ExecuteNonQueryCount);
Assert.That(Log4NetCommand.MostRecentInstance, Is.Not.Null);
Assert.That(Log4NetCommand.MostRecentInstance!.ExecuteNonQueryCount, Is.EqualTo(bufferSize + 1));
}

[Test]
Expand Down Expand Up @@ -150,25 +150,23 @@ public void WebsiteExample()
log.Debug("Message");

IDbCommand? command = Log4NetCommand.MostRecentInstance;
Assert.NotNull(command);
Assert.That(command, Is.Not.Null);

Assert.AreEqual(
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
command!.CommandText);

Assert.AreEqual(6, command.Parameters.Count);
Assert.That(command.CommandText,
Is.EqualTo("INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"));
Assert.That(command.Parameters, Has.Count.EqualTo(6));

IDbDataParameter param = (IDbDataParameter)command.Parameters["@message"];
Assert.AreEqual("Message", param.Value);
Assert.That(param.Value, Is.EqualTo("Message"));

param = (IDbDataParameter)command.Parameters["@log_level"];
Assert.AreEqual(Level.Debug.ToString(), param.Value);
Assert.That(param.Value, Is.EqualTo(Level.Debug.ToString()));

param = (IDbDataParameter)command.Parameters["@logger"];
Assert.AreEqual("WebsiteExample", param.Value);
Assert.That(param.Value, Is.EqualTo("WebsiteExample"));

param = (IDbDataParameter)command.Parameters["@exception"];
Assert.IsEmpty((string?)param.Value);
Assert.That((string?)param.Value, Is.Empty);
}

[Test]
Expand Down Expand Up @@ -242,25 +240,24 @@ public void BufferingWebsiteExample()
}

IDbCommand? command = Log4NetCommand.MostRecentInstance;
Assert.NotNull(command);
Assert.That(command, Is.Not.Null);

Assert.AreEqual(
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
command!.CommandText);
Assert.That(command!.CommandText,
Is.EqualTo("INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"));

Assert.AreEqual(6, command.Parameters.Count);
Assert.That(command.Parameters, Has.Count.EqualTo(6));

IDbDataParameter param = (IDbDataParameter)command.Parameters["@message"];
Assert.AreEqual("Message", param.Value);
Assert.That(param.Value, Is.EqualTo("Message"));

param = (IDbDataParameter)command.Parameters["@log_level"];
Assert.AreEqual(Level.Debug.ToString(), param.Value);
Assert.That(param.Value, Is.EqualTo(Level.Debug.ToString()));

param = (IDbDataParameter)command.Parameters["@logger"];
Assert.AreEqual("WebsiteExample", param.Value);
Assert.That(param.Value, Is.EqualTo("WebsiteExample"));

param = (IDbDataParameter)command.Parameters["@exception"];
Assert.IsEmpty((string?)param.Value);
Assert.That(param.Value, Is.Empty);
}

[Test]
Expand Down Expand Up @@ -295,11 +292,11 @@ public void NullPropertyXmlConfig()

log.Debug("Message");
IDbCommand? command = Log4NetCommand.MostRecentInstance;
Assert.NotNull(command);
Assert.That(command, Is.Not.Null);

IDbDataParameter param = (IDbDataParameter)command!.Parameters["@productId"];
Assert.AreNotEqual(SystemInfo.NullText, param.Value);
Assert.AreEqual(DBNull.Value, param.Value);
Assert.That(param.Value, Is.Not.EqualTo(SystemInfo.NullText));
Assert.That(param.Value, Is.EqualTo(DBNull.Value));
}

[Test]
Expand Down Expand Up @@ -332,10 +329,10 @@ public void NullPropertyProgrammaticConfig()

log.Debug("Message");
IDbCommand? command = Log4NetCommand.MostRecentInstance;
Assert.NotNull(command);
Assert.That(command, Is.Not.Null);

IDbDataParameter param = (IDbDataParameter)command!.Parameters["@productId"];
Assert.AreNotEqual(SystemInfo.NullText, param.Value);
Assert.AreEqual(DBNull.Value, param.Value);
Assert.That(param.Value, Is.Not.EqualTo(SystemInfo.NullText));
Assert.That(param.Value, Is.EqualTo(DBNull.Value));
}
}
8 changes: 4 additions & 4 deletions src/log4net.Tests/Appender/AppenderCollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void ToArrayTest()

IAppender[] appenderArray = appenderCollection.ToArray();

Assert.AreEqual(1, appenderArray.Length);
Assert.AreEqual(appender, appenderArray[0]);
Assert.That(appenderArray, Has.Length.EqualTo(1));
Assert.That(appenderArray[0], Is.EqualTo(appender));
}

[Test]
Expand All @@ -58,7 +58,7 @@ public void ReadOnlyToArrayTest()

IAppender[] appenderArray = readonlyAppenderCollection.ToArray();

Assert.AreEqual(1, appenderArray.Length);
Assert.AreEqual(appender, appenderArray[0]);
Assert.That(appenderArray, Has.Length.EqualTo(1));
Assert.That(appenderArray[0], Is.EqualTo(appender));
}
}
22 changes: 11 additions & 11 deletions src/log4net.Tests/Appender/BufferingAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public void TestSetupAppender()
{
SetupRepository();

Assert.AreEqual(0, _countingAppender.Counter, "Test empty appender");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test empty appender");

ILogger logger = _hierarchy.GetLogger("test");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message logged", null);

Assert.AreEqual(1, _countingAppender.Counter, "Test 1 event logged");
Assert.That(_countingAppender.Counter, Is.EqualTo(1), "Test 1 event logged");
}

[Test]
Expand All @@ -79,25 +79,25 @@ public void TestBufferSize5()
_bufferingForwardingAppender.BufferSize = 5;
_bufferingForwardingAppender.ActivateOptions();

Assert.AreEqual(_countingAppender.Counter, 0);
Assert.That(_countingAppender.Counter, Is.EqualTo(0));

ILogger logger = _hierarchy.GetLogger("test");

logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 1", null);
Assert.AreEqual(0, _countingAppender.Counter, "Test 1 event in buffer");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test 1 event in buffer");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 2", null);
Assert.AreEqual(0, _countingAppender.Counter, "Test 2 event in buffer");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test 2 event in buffer");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 3", null);
Assert.AreEqual(0, _countingAppender.Counter, "Test 3 event in buffer");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test 3 event in buffer");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 4", null);
Assert.AreEqual(0, _countingAppender.Counter, "Test 4 event in buffer");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test 4 event in buffer");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 5", null);
Assert.AreEqual(0, _countingAppender.Counter, "Test 5 event in buffer");
Assert.That(_countingAppender.Counter, Is.EqualTo(0), "Test 5 event in buffer");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 6", null);
Assert.AreEqual(6, _countingAppender.Counter, "Test 0 event in buffer. 6 event sent");
Assert.That(_countingAppender.Counter, Is.EqualTo(6), "Test 0 event in buffer. 6 event sent");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 7", null);
Assert.AreEqual(6, _countingAppender.Counter, "Test 1 event in buffer. 6 event sent");
Assert.That(_countingAppender.Counter, Is.EqualTo(6), "Test 1 event in buffer. 6 event sent");
logger.Log(typeof(BufferingAppenderTest), Level.Warn, "Message 8", null);
Assert.AreEqual(6, _countingAppender.Counter, "Test 2 event in buffer. 6 event sent");
Assert.That(_countingAppender.Counter, Is.EqualTo(6), "Test 2 event in buffer. 6 event sent");
}
}
30 changes: 12 additions & 18 deletions src/log4net.Tests/Appender/DebugAppenderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void NullCategoryTest()
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");

Assert.IsNull(categoryTraceListener.Category);
Assert.That(categoryTraceListener.Category, Is.Null);

Assert.IsFalse(testErrHandler.ErrorOccured);
Assert.That(testErrHandler.ErrorOccured, Is.False);

Debug.Listeners.Remove(categoryTraceListener);
}
Expand All @@ -86,7 +86,7 @@ public void EmptyStringCategoryTest()
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");

Assert.IsNull(categoryTraceListener.Category);
Assert.That(categoryTraceListener.Category, Is.Null);

Debug.Listeners.Remove(categoryTraceListener);
}
Expand All @@ -110,9 +110,9 @@ public void DefaultCategoryTest()
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");

Assert.AreEqual(
GetType().ToString(),
categoryTraceListener.Category);
Assert.That(
categoryTraceListener.Category,
Is.EqualTo(GetType().ToString()));

Debug.Listeners.Remove(categoryTraceListener);
}
Expand All @@ -137,9 +137,9 @@ public void MethodNameCategoryTest()
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");

Assert.AreEqual(
MethodInfo.GetCurrentMethod().Name,
categoryTraceListener.Category);
Assert.That(
categoryTraceListener.Category,
Is.EqualTo(MethodInfo.GetCurrentMethod().Name));

Debug.Listeners.Remove(categoryTraceListener);
}
Expand All @@ -149,19 +149,13 @@ private sealed class TestErrorHandler : IErrorHandler
public bool ErrorOccured { get; private set; }

public void Error(string message, Exception? e, ErrorCode errorCode)
{
ErrorOccured = true;
}
=> ErrorOccured = true;

public void Error(string message, Exception e)
{
Error(message, e, ErrorCode.GenericFailure);
}
=> Error(message, e, ErrorCode.GenericFailure);

public void Error(string message)
{
Error(message, null, ErrorCode.GenericFailure);
}
=> Error(message, null, ErrorCode.GenericFailure);
}
}
#endif
Loading

0 comments on commit b008475

Please sign in to comment.