diff --git a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/BenchmarkRunner.csproj b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/BenchmarkRunner.csproj index 21afcbbabf..ecddb28d53 100644 --- a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/BenchmarkRunner.csproj +++ b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/BenchmarkRunner.csproj @@ -2,13 +2,13 @@ Exe - net6.0 + net10.0 enable enable - + diff --git a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/ElementPrinterBenchmark.cs b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/ElementPrinterBenchmark.cs index f0bcae89f2..20cc338111 100644 --- a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/ElementPrinterBenchmark.cs +++ b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/ElementPrinterBenchmark.cs @@ -16,8 +16,7 @@ private static int[] FillElements(int length) for (int i = 0; i < length; i++) { - var value = new Random().Next(0, 1000); - array[i] = value; + array[i] = Random.Shared.Next(0, 1000); } return array; diff --git a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/Program.cs b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/Program.cs index fa95dd3f1c..7b8b748056 100644 --- a/collections-arrays/PrintOutArrayElements/BenchmarkRunner/Program.cs +++ b/collections-arrays/PrintOutArrayElements/BenchmarkRunner/Program.cs @@ -1,3 +1,6 @@ using BenchmarkRunner; -BenchmarkDotNet.Running.BenchmarkRunner.Run(); \ No newline at end of file +// In-process: the default out-of-process host keeps every line the benchmarks print and runs out of memory. +string[] benchmarkArgs = args.Any(a => a is "--inProcess" or "-i") ? args : [.. args, "--inProcess"]; + +BenchmarkDotNet.Running.BenchmarkRunner.Run(args: benchmarkArgs); diff --git a/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/PrintOutArrayElements.csproj b/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/PrintOutArrayElements.csproj index 74abf5c976..dfb40caafc 100644 --- a/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/PrintOutArrayElements.csproj +++ b/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/PrintOutArrayElements.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net10.0 enable enable diff --git a/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/Program.cs b/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/Program.cs index 86de76afbd..614131fdf5 100644 --- a/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/Program.cs +++ b/collections-arrays/PrintOutArrayElements/PrintOutArrayElements/Program.cs @@ -3,7 +3,7 @@ public class Program { private static readonly ElementPrinter _elementPrinter = new(); - private static readonly int[] _array = new int[] { 1, 4, 6, 7, 9, 3, 5 }; + private static readonly int[] _array = [1, 4, 6, 7, 9, 3, 5]; public static int OutPutResult = 0; public static void Main(string[] args) diff --git a/collections-arrays/PrintOutArrayElements/Tests/Tests.cs b/collections-arrays/PrintOutArrayElements/Tests/Tests.cs index 4bf20b99b8..6b6083d69b 100644 --- a/collections-arrays/PrintOutArrayElements/Tests/Tests.cs +++ b/collections-arrays/PrintOutArrayElements/Tests/Tests.cs @@ -10,7 +10,7 @@ namespace Tests public class Tests { private static readonly ElementPrinter _elementPrinter = new(); - private static readonly int[] _array = new int[] { 1, 4, 6, 7, 9, 3, 5 }; + private static readonly int[] _array = [1, 4, 6, 7, 9, 3, 5]; private const string _expectedResult = " ==> 1 ==> 4 ==> 6 ==> 7 ==> 9 ==> 3 ==> 5"; private static readonly StringBuilder _consoleOutput = new(); @@ -29,6 +29,14 @@ public void GivenTheClassProgram_WhenExecuteTheMainMethod_ThenSetTheOutPutResult Assert.AreEqual(1, Program.OutPutResult); } + [TestMethod] + public void GivenAnArray_WhenPassingItToConsoleWrite_ThenPrintOutTheTypeName() + { + Console.Write(_array); + + Assert.AreEqual("System.Int32[]", _consoleOutput.ToString()); + } + [TestMethod] public void GivenAnArray_WhenUsingForLoop_ThenPrintOutTheResultOnTheScreen() { diff --git a/collections-arrays/PrintOutArrayElements/Tests/Tests.csproj b/collections-arrays/PrintOutArrayElements/Tests/Tests.csproj index 57d19f3012..5d8603adcd 100644 --- a/collections-arrays/PrintOutArrayElements/Tests/Tests.csproj +++ b/collections-arrays/PrintOutArrayElements/Tests/Tests.csproj @@ -1,17 +1,17 @@ - net6.0 + net10.0 enable false - - - - + + + +