Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using BenchmarkRunner;

BenchmarkDotNet.Running.BenchmarkRunner.Run<ElementPrinterBenchmark>();
// 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<ElementPrinterBenchmark>(args: benchmarkArgs);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion collections-arrays/PrintOutArrayElements/Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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()
{
Expand Down
10 changes: 5 additions & 5 deletions collections-arrays/PrintOutArrayElements/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.5.1" />
<PackageReference Include="MSTest.TestFramework" Version="4.5.1" />
<PackageReference Include="coverlet.collector" Version="10.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading