From 6252dc5c6cae7100a93ead772e8dc5c03ffc9ac2 Mon Sep 17 00:00:00 2001 From: Pekka Savolainen Date: Mon, 9 Jan 2023 13:08:35 +0200 Subject: [PATCH] .Net 7 (#14) --- .vscode/launch.json | 14 ----------- Jenkinsfile | 6 ++--- ...tacon.NetCore.WebApi.TestUtil.Tests.csproj | 16 +++++-------- .../Tests/BasicFlowTests.cs | 24 +++++++++---------- .../Tests/HeaderSupportTest.cs | 4 ++-- .../Tests/WaitForContentTests.cs | 13 +++++----- .../Tests/WaitForStatusCodeTests.cs | 12 +++++----- .../Tests/WaitForTests.cs | 13 +++++----- .../Protacon.NetCore.WebApi.TestUtil.csproj | 16 +++++-------- 9 files changed, 49 insertions(+), 69 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e8d0685..e21a627 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,20 +4,6 @@ // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md "version": "0.2.0", "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceRoot}/Protacon.NetCore.WebApi.TestUtil.Tests/bin/Debug/netcoreapp3.1/Protacon.NetCore.WebApi.TestUtil.Tests.dll", - "args": [], - "cwd": "${workspaceRoot}/Protacon.NetCore.WebApi.TestUtil.Tests", - // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window - "console": "internalConsole", - "stopAtEntry": false, - "internalConsoleOptions": "openOnSessionStart" - }, { "name": ".NET Core Attach", "type": "coreclr", diff --git a/Jenkinsfile b/Jenkinsfile index 535ba83..60c2c50 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,10 @@ -library "jenkins-ptcs-library@4.0.3" +library "jenkins-ptcs-library@5.0.0" // pod provides common utilies and tools to jenkins-ptcs-library function correctly. // certain ptcs-library command requires containers (like docker or gcloud.) podTemplate(label: pod.label, containers: pod.templates + [ // This adds all depencies for jenkins-ptcs-library methods to function correctly. - containerTemplate(name: 'dotnet', image: 'mcr.microsoft.com/dotnet/sdk:6.0', ttyEnabled: true, command: '/bin/sh -c', args: 'cat') + containerTemplate(name: 'dotnet', image: 'mcr.microsoft.com/dotnet/sdk:7.0', ttyEnabled: true, command: '/bin/sh -c', args: 'cat') ] ) { node(pod.label) { @@ -21,7 +21,7 @@ podTemplate(label: pod.label, stage('Test') { container('dotnet') { sh """ - dotnet test --framework=net6.0 Protacon.NetCore.WebApi.TestUtil.Tests + dotnet test --framework=net7.0 Protacon.NetCore.WebApi.TestUtil.Tests """ } } diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Protacon.NetCore.WebApi.TestUtil.Tests.csproj b/Protacon.NetCore.WebApi.TestUtil.Tests/Protacon.NetCore.WebApi.TestUtil.Tests.csproj index b58244f..9ab9c90 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Protacon.NetCore.WebApi.TestUtil.Tests.csproj +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Protacon.NetCore.WebApi.TestUtil.Tests.csproj @@ -1,19 +1,15 @@  - net6.0;net5.0;netcoreapp3.1 + net7.0;net6.0 - - - - - - - - - + + + + + diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/BasicFlowTests.cs b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/BasicFlowTests.cs index 4197e09..e723ceb 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/BasicFlowTests.cs +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/BasicFlowTests.cs @@ -21,10 +21,10 @@ await TestHost.Run().Get("/returnthree/") .Passing( x => x.Should().Be(3)); - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.ExpectStatusCode(HttpStatusCode.NoContent)) .Should() - .Throw(); + .ThrowAsync(); } [Fact] @@ -33,9 +33,9 @@ public async Task WhenDeleteIsCalled_ThenAssertingItWorks() await TestHost.Run().Delete("/something/abc") .ExpectStatusCode(HttpStatusCode.NoContent); - TestHost.Run().Delete("/something/abc") + await TestHost.Run().Delete("/something/abc") .Awaiting(x => x.ExpectStatusCode(HttpStatusCode.NotFound)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -46,9 +46,9 @@ public async Task WhenPutIsCalled_ThenAssertingItWorks() .WithContentOf() .Passing(x => x.Value.Should().Be("3")); - TestHost.Run().Put("/returnsame/", new { value = 3 }) + await TestHost.Run().Put("/returnsame/", new { value = 3 }) .Awaiting(x => x.ExpectStatusCode(HttpStatusCode.NotFound)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -59,9 +59,9 @@ public async Task WhenPostIsCalled_ThenAssertingItWorks() .WithContentOf() .Passing(x => x.Value.Should().Be("3")); - TestHost.Run().Post("/returnsame/", new { value = 3 }) + await TestHost.Run().Post("/returnsame/", new { value = 3 }) .Awaiting(x => x.ExpectStatusCode(HttpStatusCode.NotFound)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -74,7 +74,7 @@ public async Task WhenPatchIsCalled_ThenAssertingItWorks() } [Fact] - public async Task WhenNonAcceptedCodeIsExpected_ThenAcceptItAsResult() + public async Task WhenNonAcceptedCodeIsExpected_ThenAcceptItAsResult() { await TestHost.Run().Get("/errorcontent/") .ExpectStatusCode(HttpStatusCode.NotFound) @@ -83,11 +83,11 @@ await TestHost.Run().Get("/errorcontent/") } [Fact] - public void WhenExpectedCodeIsNotDefinedOnError_ThenFail() + public async Task WhenExpectedCodeIsNotDefinedOnError_ThenFail() { - TestHost.Run().Get("/errorcontent/") + await TestHost.Run().Get("/errorcontent/") .Awaiting(x => x.WithContentOf()) - .Should().Throw(); + .Should().ThrowAsync(); } } } diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/HeaderSupportTest.cs b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/HeaderSupportTest.cs index 3581ed5..36b0578 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/HeaderSupportTest.cs +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/HeaderSupportTest.cs @@ -16,11 +16,11 @@ await TestHost.Run().Get("/headertest/", headers: new Dictionary {{"example", "somevalue"}}) .ExpectStatusCode(HttpStatusCode.NoContent); - TestHost.Run() + await TestHost.Run() .Awaiting(x => x.Get("/headertest/", headers: new Dictionary {{"somethingElse", "somevalue"}}) .ExpectStatusCode(HttpStatusCode.NoContent)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForContentTests.cs b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForContentTests.cs index aff3226..fff6a9a 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForContentTests.cs +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForContentTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using FluentAssertions; using Protacon.NetCore.WebApi.TestUtil.Extensions; using Xunit; @@ -8,19 +9,19 @@ namespace Protacon.NetCore.WebApi.TestUtil.Tests public class WaitForContentTests { [Fact] - public void WhenNoValidResponseIsReceived_ThenThrowErrorAfterTimeout() + public async Task WhenNoValidResponseIsReceived_ThenThrowErrorAfterTimeout() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitFor(r => r.Should().Be(1), TimeSpan.FromSeconds(2))) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] - public void WhenValidResponseIsReceived_ThenReturnWithoutError() + public async Task WhenValidResponseIsReceived_ThenReturnWithoutError() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitFor(r => r.Should().Be(3), TimeSpan.FromSeconds(2))) - .Should().NotThrow(); + .Should().NotThrowAsync(); } } } \ No newline at end of file diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForStatusCodeTests.cs b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForStatusCodeTests.cs index 7c79442..a462fa3 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForStatusCodeTests.cs +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForStatusCodeTests.cs @@ -10,19 +10,19 @@ namespace Protacon.NetCore.WebApi.TestUtil.Tests public class WaitForStatusCodeTests { [Fact] - public void WhenErronousCodeIsReturned_ThenThrowErrorAfterTimeout() + public async Task WhenErronousCodeIsReturned_ThenThrowErrorAfterTimeout() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitForStatusCode(HttpStatusCode.BadRequest, TimeSpan.FromSeconds(2))) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] - public void WhenValidCodeIsReturned_ThenReturnWithoutError() + public async Task WhenValidCodeIsReturned_ThenReturnWithoutError() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitForStatusCode(HttpStatusCode.OK, TimeSpan.FromSeconds(2))) - .Should().NotThrow(); + .Should().NotThrowAsync(); } } } \ No newline at end of file diff --git a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForTests.cs b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForTests.cs index 8268445..7ced179 100644 --- a/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForTests.cs +++ b/Protacon.NetCore.WebApi.TestUtil.Tests/Tests/WaitForTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using FluentAssertions; using Protacon.NetCore.WebApi.TestUtil.Extensions; using Xunit; @@ -8,19 +9,19 @@ namespace Protacon.NetCore.WebApi.TestUtil.Tests public class WaitForTests { [Fact] - public void WhenNoValidResponseIsReceived_ThenThrowErrorAfterTimeout() + public async Task WhenNoValidResponseIsReceived_ThenThrowErrorAfterTimeout() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitFor(r => r.Should().Be(1), TimeSpan.FromSeconds(2))) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] - public void WhenValidResponseIsReceived_ThenReturnWithoutError() + public async Task WhenValidResponseIsReceived_ThenReturnWithoutError() { - TestHost.Run().Get("/returnthree/") + await TestHost.Run().Get("/returnthree/") .Awaiting(x => x.WaitFor(r => r.Should().Be(3), TimeSpan.FromSeconds(2))) - .Should().NotThrow(); + .Should().NotThrowAsync(); } } } \ No newline at end of file diff --git a/Protacon.NetCore.WebApi.TestUtil/Protacon.NetCore.WebApi.TestUtil.csproj b/Protacon.NetCore.WebApi.TestUtil/Protacon.NetCore.WebApi.TestUtil.csproj index 16c2c1b..3a3011d 100644 --- a/Protacon.NetCore.WebApi.TestUtil/Protacon.NetCore.WebApi.TestUtil.csproj +++ b/Protacon.NetCore.WebApi.TestUtil/Protacon.NetCore.WebApi.TestUtil.csproj @@ -1,22 +1,18 @@  - net6.0;net5.0;netcoreapp3.1 + net7.0;net6.0 true + + + + + - - - - - - - - -