Skip to content

Commit dd17140

Browse files
authored
Merge pull request #45 from RedWall/update-test-projects
Updates test projects to .NET 8
2 parents 8b2ce6c + 15c81cb commit dd17140

File tree

13 files changed

+58
-64
lines changed

13 files changed

+58
-64
lines changed

Futilities/Futilities.Enums.Tests/Futilities.Enums.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
<PackageReference Include="coverlet.collector" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Futilities/Futilities.FileIO.Tests/Futilities.FileIO.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
<PackageReference Include="coverlet.collector" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Futilities/Futilities.Hash.Tests/Futilities.Hash.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<PackageReference Include="coverlet.collector" Version="3.1.0">
99
<PrivateAssets>all</PrivateAssets>
1010
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1111
</PackageReference>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
14-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
14+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

Futilities/Futilities.Hash.Tests/HashTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Futilities.Hash.Tests
1212
public class HashTests : TestingBase
1313
{
1414
[TestMethod]
15-
[TestProperty("Expected-MD5-Hash", "D3-6B-69-53-6B-9C-C1-47-03-95-E2-C3-8A-14-1F-5A")]
15+
[TestProperty("Expected-MD5-Hash", "92-2C-16-B0-30-3D-C8-64-0D-E8-57-C5-31-ED-D7-2A")]
1616
[TestProperty("Prop1-Value", "abcdefghijklmnopqrstuvwxyz")]
1717
[TestProperty("Prop2-Value", "9999")]
1818
[TestProperty("Prop3-Value", "1/1/2001")]
@@ -32,7 +32,7 @@ public void ComputeHash_ReturnsExpectedMD5Hash()
3232
}
3333

3434
[TestMethod]
35-
[TestProperty("Expected-SHA1-Hash", "AD-4C-EE-67-96-68-21-E3-52-A4-BE-31-18-92-2C-8D-6F-A6-0F-0D")]
35+
[TestProperty("Expected-SHA1-Hash", "C1-88-3B-4D-17-16-1D-E6-3C-23-47-75-F2-22-56-29-62-36-21-5C")]
3636
[TestProperty("Prop1-Value", "abcdefghijklmnopqrstuvwxyz")]
3737
[TestProperty("Prop2-Value", "9999")]
3838
[TestProperty("Prop3-Value", "1/1/2001")]
@@ -52,7 +52,6 @@ public void ComputeHash_ReturnsExpectedSHA1Hash()
5252
}
5353

5454
[TestMethod]
55-
[TestProperty("Expected-MD5-Hash", "D3-6B-69-53-6B-9C-C1-47-03-95-E2-C3-8A-14-1F-5A")]
5655
[TestProperty("Prop1-Value", "abcdefghijklmnopqrstuvwxyz")]
5756
[TestProperty("Prop2-Value", "9999")]
5857
[TestProperty("Prop3-Value", "1/1/2001")]

Futilities/Futilities.Hash/Futilities.Hash.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
<ProjectReference Include="..\Futilities.Shared\Futilities.Shared.csproj" />
1111
</ItemGroup>
1212

13+
<ItemGroup>
14+
<PackageReference Include="System.Text.Json" Version="8.0.4" />
15+
</ItemGroup>
16+
1317
</Project>

Futilities/Futilities.Hash/Hash.cs

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using Futilities.Shared;
22
using System;
33
using System.Collections.Generic;
4-
using System.IO;
54
using System.Linq;
65
using System.Linq.Expressions;
76
using System.Reflection;
8-
using System.Runtime.Serialization.Formatters.Binary;
97
using System.Security.Cryptography;
108
using System.Text;
9+
using System.Text.Json;
1110

1211
namespace Futilities.Hashing
1312
{
@@ -24,34 +23,26 @@ public static string ComputeHash<T>(this T obj, HashingAlgorithm algorithm = Has
2423
if (obj is null)
2524
return null;
2625

27-
using (var ms = new MemoryStream())
28-
{
29-
var formatter = new BinaryFormatter();
26+
var dict = (obj.GetObjectToCompute() as IDictionary<string, object>).ToDictionary(x => x.Key, x => x.Value);
27+
var bytes = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(dict));
3028

31-
var dict = (obj.GetObjectToCompute() as IDictionary<string, object>).ToDictionary(x => x.Key, x => x.Value);
29+
string hash = string.Empty;
3230

33-
formatter.Serialize(ms, dict);
31+
if (algorithm == HashingAlgorithm.MD5)
32+
using (var md = MD5.Create())
33+
{
34+
var hashBytes = md.ComputeHash(bytes);
35+
hash = BitConverter.ToString(hashBytes);
36+
}
3437

35-
string hash = string.Empty;
38+
if (algorithm == HashingAlgorithm.SHA1)
39+
using (var sh = SHA1.Create())
40+
{
41+
var hashBytes = sh.ComputeHash(bytes);
42+
hash = BitConverter.ToString(hashBytes);
43+
}
3644

37-
if (algorithm == HashingAlgorithm.MD5)
38-
using (var md = MD5.Create())
39-
{
40-
var bytes = md.ComputeHash(ms.ToArray());
41-
42-
hash = BitConverter.ToString(bytes);
43-
}
44-
45-
if (algorithm == HashingAlgorithm.SHA1)
46-
using (var sh = SHA1.Create())
47-
{
48-
var bytes = sh.ComputeHash(ms.ToArray());
49-
50-
hash = BitConverter.ToString(bytes);
51-
}
52-
53-
return hash;
54-
}
45+
return hash;
5546
}
5647

5748
/// <summary>

Futilities/Futilities.ListExtensions.Tests/Futilities.ListExtensions.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
<PackageReference Include="coverlet.collector" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Futilities/Futilities.ObjectExtensions.Tests/Futilities.ObjectExtensions.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
<PackageReference Include="coverlet.collector" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Futilities/Futilities.StringConversion.Tests/Futilities.StringConversion.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

Futilities/Futilities.StringParsing.Tests/Futilities.StringParsing.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12-
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
12+
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
1313
<PackageReference Include="coverlet.collector" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)