From e3a38e8354173a1f8b295cd7c6c7e6c1d8265640 Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Mon, 14 Dec 2020 14:26:00 -0800 Subject: [PATCH] Fix SDK version test --- .../NetCore31Project/NetCore31Project.csproj | 8 ++++++++ .../test-projects/NetCore31Project/Program.cs | 12 ++++++++++++ .../test-projects/NetCore31Project/global.json | 5 +++++ .../ProjectLoadListenerTests.cs | 18 +++++++++++++++--- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 test-assets/test-projects/NetCore31Project/NetCore31Project.csproj create mode 100644 test-assets/test-projects/NetCore31Project/Program.cs create mode 100644 test-assets/test-projects/NetCore31Project/global.json diff --git a/test-assets/test-projects/NetCore31Project/NetCore31Project.csproj b/test-assets/test-projects/NetCore31Project/NetCore31Project.csproj new file mode 100644 index 0000000000..23df6047ff --- /dev/null +++ b/test-assets/test-projects/NetCore31Project/NetCore31Project.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/test-assets/test-projects/NetCore31Project/Program.cs b/test-assets/test-projects/NetCore31Project/Program.cs new file mode 100644 index 0000000000..dbae8113d5 --- /dev/null +++ b/test-assets/test-projects/NetCore31Project/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ProjectAndSolution +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/test-assets/test-projects/NetCore31Project/global.json b/test-assets/test-projects/NetCore31Project/global.json new file mode 100644 index 0000000000..72b7dc3ed1 --- /dev/null +++ b/test-assets/test-projects/NetCore31Project/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.1.401" + } +} diff --git a/tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs b/tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs index 18deacf2c9..590cc1bd95 100644 --- a/tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs +++ b/tests/OmniSharp.MSBuild.Tests/ProjectLoadListenerTests.cs @@ -189,7 +189,7 @@ public async Task The_correct_project_capablities_is_emitted() } [Fact] - public async Task The_correct_sdk_version_is_emitted() + public async Task The_correct_sdk_version_is_emitted_NETCore2_1() { // Arrange var emitter = new ProjectLoadTestEventEmitter(); @@ -197,11 +197,23 @@ public async Task The_correct_sdk_version_is_emitted() using var testProject = await TestAssets.Instance.GetTestProjectAsync("NetCore21Project"); using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory)); Assert.Single(emitter.ReceivedMessages); - Assert.Equal(GetHashedFileExtension("3.1.403"), emitter.ReceivedMessages[0].SdkVersion); + Assert.Equal(GetHashedFileExtension("2.1.811"), emitter.ReceivedMessages[0].SdkVersion); } [Fact] - public async Task The_correct_sdk_version_is_emitted_2() + public async Task The_correct_sdk_version_is_emitted_NETCore3_1() + { + // Arrange + var emitter = new ProjectLoadTestEventEmitter(); + + using var testProject = await TestAssets.Instance.GetTestProjectAsync("NetCore31Project"); + using var host = CreateMSBuildTestHost(testProject.Directory, emitter.AsExportDescriptionProvider(LoggerFactory)); + Assert.Single(emitter.ReceivedMessages); + Assert.Equal(GetHashedFileExtension("3.1.401"), emitter.ReceivedMessages[0].SdkVersion); + } + + [Fact] + public async Task The_correct_sdk_version_is_emitted_NET5() { // Arrange var emitter = new ProjectLoadTestEventEmitter();