Skip to content

Commit 5709a9b

Browse files
committed
add net47 to unit test
1 parent 8b9994a commit 5709a9b

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

.github/workflows/test-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
- name: Add local NuGet repository
2525
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
2626

27-
2827
- name: Test Yubico.Core (NET47)
2928
run: dotnet test Yubico.Core/tests/unit/Yubico.Core.UnitTests.csproj -f net47 --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
3029

3130
- name: Test Yubico.YubiKey
3231
run: dotnet test Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
32+
3333
- name: Test Yubico.Core Integration tests (NET6)
3434
run: dotnet test Yubico.Core/tests/integration/Yubico.Core.IntegrationTests.csproj -f net6.0 --logger trx --settings coverlet.runsettings.xml --collect:"XPlat Code Coverage"
3535

Yubico.Core/tests/unit/Yubico.Core.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License. -->
1818
<AssemblyName>Yubico.Core.UnitTests</AssemblyName>
1919
<RootNamespace></RootNamespace>
2020

21-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
21+
<TargetFrameworks>net6.0;net8.0;net47</TargetFrameworks>
2222
<AnalysisMode>Minimum</AnalysisMode>
2323

2424
<!-- StrongName signing -->

Yubico.Core/tests/unit/Yubico/Core/Cryptography/AesGcmPrimitivesOpenSslTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public void Encrypt_Decrypt_Succeeds()
5555
Assert.True(isValid);
5656
}
5757

58+
#if !NET47
5859
[SkippableFact(typeof(System.PlatformNotSupportedException))]
5960
public void Encrypt_Decrypt_Succeeds_RandomValues_Succeed()
6061
{
@@ -95,6 +96,9 @@ public void Encrypt_Decrypt_Succeeds_RandomValues_Succeed()
9596
isValid = plaintext.AsSpan().SequenceEqual(decryptedData.AsSpan());
9697
Assert.True(isValid);
9798
}
99+
#else
100+
101+
#endif
98102

99103
private static byte[] GetKeyData(
100104
RandomNumberGenerator? random)

Yubico.Core/tests/unit/Yubico/Core/Devices/Hid/HidTranslatorTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,18 @@ public static IEnumerable<object[]> GetTestData()
166166
// Originally, I hard-coded these, but I decided that it should do
167167
// this dynamically so that newly added keyboard layouts aren't left
168168
// out of these tests.
169+
170+
#if NET6_0_OR_GREATER
169171
foreach (KeyboardLayout layout in Enum.GetValues<KeyboardLayout>())
170172
{
171173
yield return new object[] { layout, GetDataForKeyboard(layout) };
172174
}
175+
#else
176+
foreach (KeyboardLayout layout in Enum.GetValues(typeof(KeyboardLayout)))
177+
{
178+
yield return new object[] { layout, GetDataForKeyboard(layout) };
179+
}
180+
#endif
173181
}
174182

175183
// This method gets an array of tuples with the character and HID usage

Yubico.Core/tests/unit/Yubico/Core/Iso7816/CommandApduTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ public class CommandApduTests
3535
private static byte[] GenerateRandBytes(int length)
3636
{
3737
byte[] randBytes = new byte[length];
38+
#if NET6_0_OR_GREATER
3839
System.Security.Cryptography.RandomNumberGenerator.Fill(randBytes);
40+
#else
41+
System.Security.Cryptography.RandomNumberGenerator.Create().GetBytes(randBytes);
42+
#endif
43+
3944
return randBytes;
4045
}
4146

Yubico.Core/tests/unit/Yubico/Core/Tlv/TlvWriterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public void EncodeTag_Has_Correct_LengthAndOffset()
478478
var reader = new TlvReader(encoding);
479479
Assert.Equal(bytesSize, reader.PeekLength());
480480

481-
var bytesAsHex = encoding[..9].Select(b => b.ToString("X2"));
481+
var bytesAsHex = encoding.AsSpan()[..9].ToArray().Select(b => b.ToString("X2"));
482482
PrettyPrint(bytesSize, bytesAsHex);
483483

484484
// Increase for next round

0 commit comments

Comments
 (0)