Skip to content

Commit 6b822fc

Browse files
committed
test: add tests for .NET Core 3
1 parent ccc2b5b commit 6b822fc

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

build.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,14 @@ exec dotnet pack --no-restore --no-build --configuration $Configuration -o $arti
5555
exec dotnet build --configuration $Configuration "$PSScriptRoot/docs/samples/samples.sln"
5656

5757
[string[]] $testArgs=@()
58-
if ($PSVersionTable.PSEdition -eq 'Core' -and -not $IsWindows) {
59-
$testArgs += '--framework','netcoreapp2.2'
58+
if (-not $IsWindows) {
59+
$testArgs += '-p:TestFullFramework=false'
6060
}
6161
if ($env:TF_BUILD) {
6262
$testArgs += '--logger', 'trx'
6363
}
6464

65-
exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' `
66-
"$PSScriptRoot/test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj" `
67-
@testArgs `
68-
@MSBuildArgs
69-
70-
exec dotnet test --no-restore --no-build --configuration $Configuration '-clp:Summary' `
71-
"$PSScriptRoot/test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj" `
65+
exec dotnet test --no-restore --no-build --configuration $Configuration `
7266
@testArgs `
7367
@MSBuildArgs
7468

test/CommandLineUtils.Tests/McMaster.Extensions.CommandLineUtils.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
5+
<TargetFrameworks Condition="'$(TestFullFramework)' != 'false'">$(TargetFrameworks);net472</TargetFrameworks>
56
</PropertyGroup>
67

78
<ItemGroup>

test/CommandLineUtils.Tests/OptionAttributeTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,16 @@ public void BindsToStaticProperties()
241241
Assert.Equal(1, PrivateSetterProgram.StaticNumber);
242242
}
243243

244+
#if !NETCOREAPP3_0
245+
// .NET Core 3.0 made an intentional breaking change
246+
// see https://github.com/dotnet/coreclr/issues/21268
244247
[Fact]
245248
public void BindsToStaticReadOnlyProps()
246249
{
247250
CommandLineParser.ParseArgs<PrivateSetterProgram>("--static-string", "1");
248251
Assert.Equal("1", PrivateSetterProgram.StaticString);
249252
}
253+
#endif
250254

251255
[Fact]
252256
public void BindsToStaticPropertiesWithSetterMethod()

test/CommandLineUtils.Tests/ValueParserProviderTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public void ParsesValueTupleOfBoolAndEnum(string input, Color expected)
415415
[InlineData(Color.Green)]
416416
public void ParsesNullableEnum(Color? color)
417417
{
418-
var parsed = CommandLineParser.ParseArgs<Program>("--color-opt", color.ToString().ToLowerInvariant());
418+
var parsed = CommandLineParser.ParseArgs<Program>("--color-opt", color!.ToString()!.ToLowerInvariant());
419419
Assert.True(parsed.ColorOpt.HasValue, "Option should have value");
420420
Assert.Equal(color, parsed.ColorOpt);
421421
}
@@ -491,7 +491,7 @@ public void DefaultCultureCanBeChanged(string property, string option, string te
491491
app.Conventions.UseAttributes();
492492
app.Parse(option, test);
493493

494-
var actual = typeof(Program).GetProperty(property).GetMethod.Invoke(app.Model, null);
494+
var actual = typeof(Program).GetProperty(property)!.GetMethod!.Invoke(app.Model, null);
495495
Assert.Equal(expected, actual);
496496
}
497497

@@ -569,7 +569,7 @@ public static TheoryData<Type, string, object> TupleData
569569
};
570570

571571
private static readonly MethodInfo s_ItParsesOptionOfTImpl
572-
= typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesOptionOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance);
572+
= typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesOptionOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance)!;
573573

574574
private void ItParsesOptionOfTImpl<T>(string input, T expected)
575575
{
@@ -581,7 +581,7 @@ private void ItParsesOptionOfTImpl<T>(string input, T expected)
581581
}
582582

583583
private static readonly MethodInfo s_ItParsesArgumentOfTImpl
584-
= typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesArgumentOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance);
584+
= typeof(ValueParserProviderTests).GetMethod(nameof(ItParsesArgumentOfTImpl), BindingFlags.NonPublic | BindingFlags.Instance)!;
585585

586586
private void ItParsesArgumentOfTImpl<T>(string input, T expected)
587587
{

test/Hosting.CommandLine.Tests/McMaster.Extensions.Hosting.CommandLine.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2</TargetFrameworks>
5+
<TargetFrameworks Condition="'$(TestFullFramework)' != 'false'">$(TargetFrameworks);net472</TargetFrameworks>
56
</PropertyGroup>
67

78
<ItemGroup>

0 commit comments

Comments
 (0)