You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by fr...@apache.org on 2024/10/22 09:40:19 UTC

(logging-log4net) branch Feature/NUnitBump updated: switched to NUnit 4.2.2

This is an automated email from the ASF dual-hosted git repository.

freeandnil pushed a commit to branch Feature/NUnitBump
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git


The following commit(s) were added to refs/heads/Feature/NUnitBump by this push:
     new 1a552fe0 switched to NUnit 4.2.2
1a552fe0 is described below

commit 1a552fe0b0780be2303f7788bd2371f4d69ae7a5
Author: Jan Friedrich <fr...@apache.org>
AuthorDate: Tue Oct 22 11:40:11 2024 +0200

    switched to NUnit 4.2.2
---
 src/Directory.Build.props                          |  2 +-
 .../Appender/SmtpPickupDirAppenderTest.cs          |  9 ++--
 src/log4net.Tests/Util/SystemInfoTest.cs           | 57 +++++++++-------------
 3 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index a0d3ee37..033b3ace 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -13,7 +13,7 @@
     <!-- Test Packages -->
     <MicrosoftNetTestSdkPackageVersion>17.11.1</MicrosoftNetTestSdkPackageVersion>
     <NUnitAnalyzersPackageVersion>4.3.0</NUnitAnalyzersPackageVersion>
-    <NUnitPackageVersion>3.14.0</NUnitPackageVersion>
+    <NUnitPackageVersion>4.2.2</NUnitPackageVersion>
     <NUnit3TestAdapterPackageVersion>4.6.0</NUnit3TestAdapterPackageVersion>
     <QuackersTestLoggerPackageVersion>1.0.25</QuackersTestLoggerPackageVersion>
   </PropertyGroup>
diff --git a/src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs b/src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs
index e59ca09c..da1eb3b9 100644
--- a/src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs
+++ b/src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs
@@ -64,7 +64,7 @@ public class SmtpPickupDirAppenderTest
   /// with all appenders, and deletes any test files used
   /// for logging.
   /// </summary>
-  private void ResetLogger()
+  private static void ResetLogger()
   {
     // Regular users should not use the clear method lightly!
     LogManager.GetRepository().ResetConfiguration();
@@ -110,7 +110,7 @@ public class SmtpPickupDirAppenderTest
   /// </summary>
   /// <param name="appender">The appender to use</param>
   /// <returns>A configured ILogger</returns>
-  private ILogger CreateLogger(SmtpPickupDirAppender appender)
+  private static ILogger CreateLogger(SmtpPickupDirAppender appender)
   {
     Repository.Hierarchy.Hierarchy h = (Repository.Hierarchy.Hierarchy)LogManager.CreateRepository("TestRepository");
 
@@ -178,7 +178,8 @@ public class SmtpPickupDirAppenderTest
         string datePart = line.Substring(dateHeaderStart.Length);
         DateTime date = DateTime.ParseExact(datePart, "r", System.Globalization.CultureInfo.InvariantCulture);
         double diff = Math.Abs((DateTime.UtcNow - date).TotalMilliseconds);
-        Assert.LessOrEqual(diff, 1000, "Times should be equal, allowing a diff of one second to make test robust");
+        Assert.That(diff, Is.LessThanOrEqualTo(1000),
+          "Times should be equal, allowing a diff of one second to make test robust");
         hasDateHeader = true;
       }
     }
@@ -191,6 +192,8 @@ public class SmtpPickupDirAppenderTest
   /// Verifies that file extension is applied to output file name.
   /// </summary>
   [Test]
+  [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1846:Prefer 'AsSpan' over 'Substring'",
+    Justification = "only .net8")]
   public void TestConfigurableFileExtension()
   {
     Utils.InconclusiveOnMono();
diff --git a/src/log4net.Tests/Util/SystemInfoTest.cs b/src/log4net.Tests/Util/SystemInfoTest.cs
index 957b22a4..8b6aff05 100644
--- a/src/log4net.Tests/Util/SystemInfoTest.cs
+++ b/src/log4net.Tests/Util/SystemInfoTest.cs
@@ -60,10 +60,10 @@ public class SystemInfoTest
     return Expression.Lambda<Func<string>>(methodCall, Array.Empty<ParameterExpression>()).Compile();
   }
 
-  public static string TestAssemblyLocationInfoMethod()
-  {
-    return SystemInfo.AssemblyLocationInfo(Assembly.GetCallingAssembly());
-  }
+  [System.Diagnostics.CodeAnalysis.SuppressMessage("Structure", "NUnit1028:The non-test method is public",
+    Justification = "Reflection")]
+  public static string TestAssemblyLocationInfoMethod() 
+    => SystemInfo.AssemblyLocationInfo(Assembly.GetCallingAssembly());
 
   [Test]
   public void TestGetTypeFromStringFullyQualified()
@@ -131,9 +131,10 @@ public class SystemInfoTest
     Type? t;
 
     t = GetTypeFromString("LOG4NET.TESTS.UTIL.SYSTEMINFOTEST,LOG4NET.TESTS", false, false);
-    Assert.That(t, Is.SameAs(null), "Test explicit case sensitive fails type load");
+    Assert.That(t, Is.Null, "Test explicit case sensitive fails type load");
 
-    Assert.Throws<TypeLoadException>(() => GetTypeFromString("LOG4NET.TESTS.UTIL.SYSTEMINFOTEST,LOG4NET.TESTS", true, false));
+    Assert.Throws<TypeLoadException>(
+      () => GetTypeFromString("LOG4NET.TESTS.UTIL.SYSTEMINFOTEST,LOG4NET.TESTS", true, false));
   }
 
   [Test]
@@ -142,7 +143,7 @@ public class SystemInfoTest
     Type? t;
 
     t = GetTypeFromString("LOG4NET.TESTS.UTIL.SYSTEMINFOTEST", false, false);
-    Assert.That(t, Is.SameAs(null), "Test explicit case sensitive fails type load");
+    Assert.That(t, Is.Null, "Test explicit case sensitive fails type load");
 
     Assert.Throws<TypeLoadException>(() => GetTypeFromString("LOG4NET.TESTS.UTIL.SYSTEMINFOTEST", true, false));
   }
@@ -150,44 +151,30 @@ public class SystemInfoTest
   // Wraps SystemInfo.GetTypeFromString because the method relies on GetCallingAssembly, which is
   // unavailable in CoreFX. As a workaround, only overloads which explicitly take a Type or Assembly
   // are exposed for NETSTANDARD1_3.
-  private Type? GetTypeFromString(string typeName, bool throwOnError, bool ignoreCase)
-  {
-    return SystemInfo.GetTypeFromString(typeName, throwOnError, ignoreCase);
-  }
+  private static Type? GetTypeFromString(string typeName, bool throwOnError, bool ignoreCase) 
+    => SystemInfo.GetTypeFromString(typeName, throwOnError, ignoreCase);
 
   [Test]
-  public void EqualsIgnoringCase_BothNull_true()
-  {
-    Assert.True(SystemInfo.EqualsIgnoringCase(null, null));
-  }
+  public void EqualsIgnoringCase_BothNull_true() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase(null, null), Is.True);
 
   [Test]
-  public void EqualsIgnoringCase_LeftNull_false()
-  {
-    Assert.False(SystemInfo.EqualsIgnoringCase(null, "foo"));
-  }
+  public void EqualsIgnoringCase_LeftNull_false() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase(null, "foo"), Is.False);
 
   [Test]
-  public void EqualsIgnoringCase_RightNull_false()
-  {
-    Assert.False(SystemInfo.EqualsIgnoringCase("foo", null));
-  }
+  public void EqualsIgnoringCase_RightNull_false() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase("foo", null), Is.False);
 
   [Test]
-  public void EqualsIgnoringCase_SameStringsSameCase_true()
-  {
-    Assert.True(SystemInfo.EqualsIgnoringCase("foo", "foo"));
-  }
+  public void EqualsIgnoringCase_SameStringsSameCase_true() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase("foo", "foo"), Is.True);
 
   [Test]
-  public void EqualsIgnoringCase_SameStringsDifferentCase_true()
-  {
-    Assert.True(SystemInfo.EqualsIgnoringCase("foo", "FOO"));
-  }
+  public void EqualsIgnoringCase_SameStringsDifferentCase_true() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase("foo", "FOO"), Is.True);
 
   [Test]
-  public void EqualsIgnoringCase_DifferentStrings_false()
-  {
-    Assert.False(SystemInfo.EqualsIgnoringCase("foo", "foobar"));
-  }
+  public void EqualsIgnoringCase_DifferentStrings_false() 
+    => Assert.That(SystemInfo.EqualsIgnoringCase("foo", "foobar"), Is.False);
 }