Browse Source

Collection expressions and constants

Brandon Thetford 1 year ago
parent
commit
c50c4559d0
2 changed files with 7 additions and 5 deletions
  1. 6 4
      UnitTests/TestHelpers.cs
  2. 1 1
      UnitTests/View/DrawTests.cs

+ 6 - 4
UnitTests/TestHelpers.cs

@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using System.Diagnostics;
 using System.Globalization;
 using System.Globalization;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
@@ -173,6 +173,8 @@ public class TestDateAttribute : BeforeAfterTestAttribute
 
 
 internal partial class TestHelpers
 internal partial class TestHelpers
 {
 {
+    private const char SpaceChar = ' ';
+    private static readonly Rune SpaceRune = (Rune)SpaceChar;
 #pragma warning disable xUnit1013 // Public method should be marked as test
 #pragma warning disable xUnit1013 // Public method should be marked as test
     /// <summary>
     /// <summary>
     ///     Verifies <paramref name="expectedAttributes"/> are found at the locations specified by
     ///     Verifies <paramref name="expectedAttributes"/> are found at the locations specified by
@@ -330,13 +332,13 @@ internal partial class TestHelpers
 
 
         for (var r = 0; r < driver.Rows; r++)
         for (var r = 0; r < driver.Rows; r++)
         {
         {
-            List<Rune> runes = new ();
+            List<Rune> runes = [];
 
 
             for (var c = 0; c < driver.Cols; c++)
             for (var c = 0; c < driver.Cols; c++)
             {
             {
                 Rune rune = contents [r, c].Rune;
                 Rune rune = contents [r, c].Rune;
 
 
-                if (rune != (Rune)' ')
+                if (runeAtCurrentLocation != SpaceRune)
                 {
                 {
                     if (x == -1)
                     if (x == -1)
                     {
                     {
@@ -345,7 +347,7 @@ internal partial class TestHelpers
 
 
                         for (var i = 0; i < c; i++)
                         for (var i = 0; i < c; i++)
                         {
                         {
-                            runes.InsertRange (i, new List<Rune> { (Rune)' ' });
+                            runes.InsertRange (i, [SpaceRune]);
                         }
                         }
                     }
                     }
 
 

+ 1 - 1
UnitTests/View/DrawTests.cs

@@ -12,7 +12,7 @@ public class DrawTests
     [AutoInitShutdown]
     [AutoInitShutdown]
     public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two ()
     public void CJK_Compatibility_Ideographs_ConsoleWidth_ColumnWidth_Equal_Two ()
     {
     {
-        var us = "\U0000f900";
+        const string us = "\U0000f900";
         var r = (Rune)0xf900;
         var r = (Rune)0xf900;
 
 
         Assert.Equal ("豈", us);
         Assert.Equal ("豈", us);