From 18c96525d6091bd9d5480663eba43a47c5ad4258 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 12:47:45 +1000 Subject: [PATCH 01/34] Update pipeline: use ubuntu instead of windows, use the latest actions, and simplify flow --- .github/workflows/pipeline.yml | 53 ++++++++++++---------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2e97c1d..55025a7 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -29,55 +29,40 @@ env: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: + - name: Set version id: versioner run: | - if($env:GITHUB_EVENT_NAME -like "release") { - #example refs/tags/v2.0.33 - $parts = $env:GITHUB_REF.Split("/") - $version=$parts[2] - # remove the V from the version, .net builder doesn't accept strings - $version = $version.Replace("v", "") - SET $version=%version:~1% - } - else { - $version="0.0.$env:GITHUB_RUN_NUMBER" - } + if [[ ${{ github.event_name }} == 'release' ]]; then + version="${github.ref##*/}" + version="${version/[^0-9.]/}" + else + version="0.0.${{ github.run_number }}" + # Add your commands for non-release events (command B) + fi + + echo "${{ github.event_name }} ${{ github.ref }} generated version $version" echo "::set-output name=VERSION::$version" - Write-Host "$env:GITHUB_EVENT_NAME ($env:GITHUB_REF) generated version $version" + - name: Setup .NET core 3.1.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '3.1.x' - - uses: actions/checkout@v2 - - name: Create folder - run: mkdir BuildReports + - uses: actions/checkout@v4 - name: Install dependencies - run: dotnet restore --verbosity m > BuildReports/Restore.txt + run: dotnet restore --verbosity m - name: Build - run: | - Write-Host "Version ${{steps.versioner.outputs.VERSION}}" - dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.VERSION }} > BuildReports/Build.txt + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.VERSION }} - name: Test - run: dotnet test --no-build --configuration Release > BuildReports/Tests.txt + run: dotnet test --no-build --configuration Release - name: Copy generated nuget file - shell: bash run: find . -name "SystemTestingTools*.nupkg" -exec cp "{}" ./ \; - - name: Set build report artifacts - if: ${{ always() }} # run this step even if previous steps failed - uses: actions/upload-artifact@v2 - with: - name: BuildReports - path: | - BuildReports/** - retention-days: 7 - if-no-files-found: error - name: Set nuget package artifact if: ${{ success() }} # run this step even if previous steps failed - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: NugetPackage path: SystemTestingTools*.nupkg @@ -89,7 +74,7 @@ jobs: if: github.event_name == 'release' runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: NugetPackage - name: Push to NuGet Feed From 49b03cddbc21329ead3293d7ff876e144a8839ab Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 12:57:40 +1000 Subject: [PATCH 02/34] fixes --- .github/workflows/pipeline.yml | 4 ++-- .../SystemTestingTools/Internal/RecordingFormatter.cs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 55025a7..1698977 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: fi echo "${{ github.event_name }} ${{ github.ref }} generated version $version" - echo "::set-output name=VERSION::$version" + export VERSION=$version - name: Setup .NET core 3.1.x uses: actions/setup-dotnet@v4 @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.VERSION }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=$version - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 4c564f5..1ba1a0c 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -188,7 +188,16 @@ private static HttpRequestMessage GetRequest(string requestContent) var result = new HttpRequestMessage(); - result.Method = new HttpMethod(match.Groups[1].Value); + var method = match.Groups[1].Value; + try + { + result.Method = new HttpMethod(method); + } + catch (System.FormatException ex) + { + throw new Exception($"Method {method} is invalid", ex); + } + result.RequestUri = new Uri(match.Groups[2].Value); result.Content = Helper.ParseHeadersAndBody(match.Groups[3].Value, match.Groups[5].Value, result.Headers); From 9da9745ed350885c6157a9eed54aade69b88499d Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 12:57:40 +1000 Subject: [PATCH 03/34] fixes --- .github/workflows/pipeline.yml | 4 ++-- .../SystemTestingTools/Internal/RecordingFormatter.cs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 55025a7..d4981d0 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: fi echo "${{ github.event_name }} ${{ github.ref }} generated version $version" - echo "::set-output name=VERSION::$version" + export VERSION=$version - name: Setup .NET core 3.1.x uses: actions/setup-dotnet@v4 @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.VERSION }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=$VERSION - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 4c564f5..1ba1a0c 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -188,7 +188,16 @@ private static HttpRequestMessage GetRequest(string requestContent) var result = new HttpRequestMessage(); - result.Method = new HttpMethod(match.Groups[1].Value); + var method = match.Groups[1].Value; + try + { + result.Method = new HttpMethod(method); + } + catch (System.FormatException ex) + { + throw new Exception($"Method {method} is invalid", ex); + } + result.RequestUri = new Uri(match.Groups[2].Value); result.Content = Helper.ParseHeadersAndBody(match.Groups[3].Value, match.Groups[5].Value, result.Headers); From 546aa185968d0c7beca6e31f5637a1d4a332b1b5 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:08:22 +1000 Subject: [PATCH 04/34] try access environment variable --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index d4981d0..fcbffff 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=$VERSION + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ env.VERSION }} - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file From a2539e2924ff1a3a6091c234f81b4673533f8848 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:25:05 +1000 Subject: [PATCH 05/34] another attempt --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index fcbffff..cf18b0f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ env.VERSION }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ vars.VERSION }} - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file From c262d03b8848926f5105c2458d0e6b03ecdd9f33 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:27:44 +1000 Subject: [PATCH 06/34] another try --- .github/workflows/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index cf18b0f..ab10bfe 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: fi echo "${{ github.event_name }} ${{ github.ref }} generated version $version" - export VERSION=$version + echo "::set-env name=Version::version" - name: Setup .NET core 3.1.x uses: actions/setup-dotnet@v4 @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ vars.VERSION }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ env.Version }} - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file From 8193674e54ec0189926ccc27be6996a7f85dd9c5 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:31:34 +1000 Subject: [PATCH 07/34] another try --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index ab10bfe..1d4f6c4 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: fi echo "${{ github.event_name }} ${{ github.ref }} generated version $version" - echo "::set-env name=Version::version" + echo "Version=${version}" >> $GITHUB_ENV - name: Setup .NET core 3.1.x uses: actions/setup-dotnet@v4 From 1a2daf2f7ab7682d6d902f2d4c7286f362bcef78 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:37:41 +1000 Subject: [PATCH 08/34] another try --- .github/workflows/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 1d4f6c4..a7675b5 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: fi echo "${{ github.event_name }} ${{ github.ref }} generated version $version" - echo "Version=${version}" >> $GITHUB_ENV + echo "Version=${version}" >> $GITHUB_OUTPUT - name: Setup .NET core 3.1.x uses: actions/setup-dotnet@v4 @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ env.Version }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ steps.versioner.outputs.Version }} - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file From 05aa69648291156ae55c9a91386953de28231b7e Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:41:19 +1000 Subject: [PATCH 09/34] another try --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a7675b5..8d05399 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: dotnet restore --verbosity m - name: Build - run: dotnet build --no-restore --verbosity m --configuration Release /p:Version= ${{ steps.versioner.outputs.Version }} + run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.Version }} - name: Test run: dotnet test --no-build --configuration Release - name: Copy generated nuget file From ca3b0126bac068cb42a9ad7db516e16f4544b41d Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 13:55:16 +1000 Subject: [PATCH 10/34] Changes to work in ubuntu --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 1ba1a0c..4fbc91b 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -179,7 +179,7 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { var match = RequestRegex.Match(requestContent); From fc4851fc51b8de34a23f340e46187b0e297aff81 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 14:24:42 +1000 Subject: [PATCH 11/34] Better handling new lines for windows and linux --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 4fbc91b..cc193b0 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -179,7 +179,7 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)(\r|\n)+(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { var match = RequestRegex.Match(requestContent); From 30b693f914845ff55fcdfb65704dbdb1d5069b08 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 14:35:16 +1000 Subject: [PATCH 12/34] another attempt around linux line breaks --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index cc193b0..04bc2a9 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -179,7 +179,7 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)(\r|\n)+(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)(\r\n|\r|\n)(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { var match = RequestRegex.Match(requestContent); From b18d33f36b97245adc7613667f72cd1a2c705f63 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 14:47:53 +1000 Subject: [PATCH 13/34] Handling linux new line formatting --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 04bc2a9..70cb588 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -5,6 +5,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; +using System.ServiceModel.Channels; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -182,7 +183,9 @@ public static Recording Read(string content) private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)(\r\n|\r|\n)(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { - var match = RequestRegex.Match(requestContent); + requestContent = requestContent.Replace("\r\n", "").Trim(); + + var match = RequestRegex.Match(requestContent); if (!match.Success) throw new ApplicationException("Could not parse request data"); From b6399cc0e30a7c0a5a568732afc4b35278213cd2 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 14:54:13 +1000 Subject: [PATCH 14/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 70cb588..db3776a 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -180,10 +180,10 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)(\r\n|\r|\n)(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)\n(.+?)\n\n(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { - requestContent = requestContent.Replace("\r\n", "").Trim(); + requestContent = requestContent.Replace("\r", "").Trim(); var match = RequestRegex.Match(requestContent); From d412be9a8d4c97c1d9e8b541f3ad6b6ee1fd51dd Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:18:50 +1000 Subject: [PATCH 15/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index db3776a..0a728fd 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -180,14 +180,12 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?)\s+(.+?)\n(.+?)\n\n(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { - requestContent = requestContent.Replace("\r", "").Trim(); - var match = RequestRegex.Match(requestContent); - if (!match.Success) throw new ApplicationException("Could not parse request data"); + if (!match.Success) throw new ApplicationException($"Could not parse request data"); var result = new HttpRequestMessage(); From 901b945ea1ba0a8ae8ccc6c8cb1111004f815fcb Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:24:17 +1000 Subject: [PATCH 16/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 0a728fd..0093d86 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -180,7 +180,7 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"^(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { var match = RequestRegex.Match(requestContent); @@ -189,7 +189,7 @@ private static HttpRequestMessage GetRequest(string requestContent) var result = new HttpRequestMessage(); - var method = match.Groups[1].Value; + var method = match.Groups[1].Value.Trim(); try { result.Method = new HttpMethod(method); From 4909ae65076cd27b126fb3482cc9f0ea73b02b06 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:35:02 +1000 Subject: [PATCH 17/34] another test --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 0093d86..25978e5 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -180,7 +180,7 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"^(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"^([^ ]+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { var match = RequestRegex.Match(requestContent); @@ -196,7 +196,7 @@ private static HttpRequestMessage GetRequest(string requestContent) } catch (System.FormatException ex) { - throw new Exception($"Method {method} is invalid", ex); + throw new Exception($"Method [{method}] is invalid", ex); } result.RequestUri = new Uri(match.Groups[2].Value); From cf6a29684a68e2d2fc4064ff10e73495fcccae90 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:40:38 +1000 Subject: [PATCH 18/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 25978e5..4f65ac2 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -180,10 +180,10 @@ public static Recording Read(string content) // headers // white space // body (if any) - private static Regex RequestRegex = new Regex(@"^([^ ]+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RequestRegex = new Regex(@"^(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { - var match = RequestRegex.Match(requestContent); + var match = RequestRegex.Match(requestContent.TrimStart()); if (!match.Success) throw new ApplicationException($"Could not parse request data"); From eff19f259440e7382691db0d0f9de249b76f0cbe Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:42:27 +1000 Subject: [PATCH 19/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 4f65ac2..3f9040e 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -196,7 +196,7 @@ private static HttpRequestMessage GetRequest(string requestContent) } catch (System.FormatException ex) { - throw new Exception($"Method [{method}] is invalid", ex); + throw new Exception($"Method [{method}] is invalid, {match.Groups[0]}", ex); } result.RequestUri = new Uri(match.Groups[2].Value); From c4ef94e93ba6c1b9f2e8324f739ddebdbf7b9726 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:44:15 +1000 Subject: [PATCH 20/34] another one --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 3f9040e..9a31e82 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -196,7 +196,7 @@ private static HttpRequestMessage GetRequest(string requestContent) } catch (System.FormatException ex) { - throw new Exception($"Method [{method}] is invalid, {match.Groups[0]}", ex); + throw new Exception($"Method [{method}] is invalid, {requestContent}", ex); } result.RequestUri = new Uri(match.Groups[2].Value); From 2ece53ec9aad3a7990f98d77cb21839208be0835 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:48:58 +1000 Subject: [PATCH 21/34] another try --- Tool/SystemTestingTools/Internal/RecordingFormatter.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs index 9a31e82..b3106e2 100644 --- a/Tool/SystemTestingTools/Internal/RecordingFormatter.cs +++ b/Tool/SystemTestingTools/Internal/RecordingFormatter.cs @@ -154,7 +154,7 @@ public static bool IsValid(string content) // part 1 = date time of the recording // part 2 = request details // part 3 = response details - private static Regex RecordingRegex = new Regex(@".+?\nDate:(.+?)\n.+?REQUEST.+?\n(.+?)--\!\?@Divider:.+?\n(.*)", RegexOptions.Compiled | RegexOptions.Singleline); + private static Regex RecordingRegex = new Regex(@".+?\nDate:(.+?)\n.+?REQUEST.*?\n(.+?)--\!\?@Divider:.+?\n(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static Regex DateRegex = new Regex(@"(2.+?)\(", RegexOptions.Compiled | RegexOptions.Singleline); @@ -183,7 +183,7 @@ public static Recording Read(string content) private static Regex RequestRegex = new Regex(@"^(.+?) (.+?)\n(.+?)(\r\r|\n\n|\r\n\r\n)(.*)", RegexOptions.Compiled | RegexOptions.Singleline); private static HttpRequestMessage GetRequest(string requestContent) { - var match = RequestRegex.Match(requestContent.TrimStart()); + var match = RequestRegex.Match(requestContent); if (!match.Success) throw new ApplicationException($"Could not parse request data"); @@ -196,7 +196,7 @@ private static HttpRequestMessage GetRequest(string requestContent) } catch (System.FormatException ex) { - throw new Exception($"Method [{method}] is invalid, {requestContent}", ex); + throw new Exception($"Method [{method}] is invalid", ex); } result.RequestUri = new Uri(match.Groups[2].Value); From d41e0ce41a4112481d4627a22f0b6a4abd2ba16a Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 16:59:01 +1000 Subject: [PATCH 22/34] adding test report --- .github/workflows/pipeline.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 8d05399..92a8efb 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -57,7 +57,14 @@ jobs: - name: Build run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.Version }} - name: Test - run: dotnet test --no-build --configuration Release + run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() # run this step even if previous step failed + with: + name: NUnit Tests # Name of the check run which will be created + path: TestResults/test-results.trx # Path to test results + reporter: dotnet-trx # Format of test results - name: Copy generated nuget file run: find . -name "SystemTestingTools*.nupkg" -exec cp "{}" ./ \; - name: Set nuget package artifact From 41ce08ffc104e36d5926f45e725a8d6bbbaabc39 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 17:15:59 +1000 Subject: [PATCH 23/34] Another try --- .github/workflows/pipeline.yml | 8 ++++---- Tool/SystemTestingTools/ValueObjects/FileFullPath.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 92a8efb..c8b651d 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -60,11 +60,11 @@ jobs: run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" - name: Test Report uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed + if: success() || failure() with: - name: NUnit Tests # Name of the check run which will be created - path: TestResults/test-results.trx # Path to test results - reporter: dotnet-trx # Format of test results + name: Tests Report + path: TestResults/test-results.trx + reporter: dotnet-trx - name: Copy generated nuget file run: find . -name "SystemTestingTools*.nupkg" -exec cp "{}" ./ \; - name: Set nuget package artifact diff --git a/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs b/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs index 230c467..cb03ec6 100644 --- a/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs +++ b/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using static SystemTestingTools.Helper; using static SystemTestingTools.Internal.Enums; @@ -17,7 +18,13 @@ public class FileFullPath : StringValueObject public FileFullPath(string value) : base(value) { if (!Path.HasExtension(_value)) _value += ".txt"; - if (!File.Exists(_value)) throw new ArgumentException($"Could not find file '{_value}'"); + var folder = Path.GetDirectoryName(_value); + if (!Directory.Exists(folder)) throw new ArgumentException($"Could not find folder '{folder}'"); + if (!File.Exists(_value)) + { + var filesCount = Directory.GetFiles(folder).Length; + throw new ArgumentException($"Could not find file '{_value}', but there are {filesCount} other files in the folder {folder}"); + } } public string ReadContent() From 262097beef0e3077d96d07629bdbabc322ef574d Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 17:51:46 +1000 Subject: [PATCH 24/34] improving error messages --- .../MockEndpointUnhappyTests.cs | 5 +++-- .../ValueObjectsTests.cs | 9 +++++--- .../ValueObjects/FileFullPath.cs | 21 +++++++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Tool/SystemTestingTools.UnitTests/MockEndpointUnhappyTests.cs b/Tool/SystemTestingTools.UnitTests/MockEndpointUnhappyTests.cs index f94419d..5801760 100644 --- a/Tool/SystemTestingTools.UnitTests/MockEndpointUnhappyTests.cs +++ b/Tool/SystemTestingTools.UnitTests/MockEndpointUnhappyTests.cs @@ -1,5 +1,6 @@ using FluentAssertions; using System; +using System.IO; using System.Text.RegularExpressions; using Xunit; @@ -22,8 +23,8 @@ public void FileDoesntExist() Action act = () => ResponseFactory.FromFiddlerLikeResponseFile(fullFileName); - var exception = Assert.Throws(act); - exception.Message.Should().Be($"Could not find file '{fullFileName}'"); + var exception = Assert.Throws(act); + exception.Message.Should().StartWith($"Could not find file '{fullFileName}', there are 0 other files in the folder "); } [Fact] diff --git a/Tool/SystemTestingTools.UnitTests/ValueObjectsTests.cs b/Tool/SystemTestingTools.UnitTests/ValueObjectsTests.cs index e918eda..1eb3a50 100644 --- a/Tool/SystemTestingTools.UnitTests/ValueObjectsTests.cs +++ b/Tool/SystemTestingTools.UnitTests/ValueObjectsTests.cs @@ -2,6 +2,7 @@ using FluentAssertions.Execution; using System; using System.IO; +using System.Numerics; using System.Text.RegularExpressions; using Xunit; @@ -54,13 +55,15 @@ public void FileFullPath_Empty_Unhappy() } [Fact] - public void FileFullPath_FileDoesntExist_Unhappy() + public void FileFullPath_FolderDoesntExist_Unhappy() { var fullFileName = FilesFolder + @"happy/401_InvalidKeyAAA"; - var ex = Assert.Throws(() => { FileFullPath file = fullFileName; }); + var ex = Assert.Throws(() => { FileFullPath file = fullFileName; }); - ex.Message.Should().Be($"Could not find file '{fullFileName}.txt'"); + var folder = Path.GetDirectoryName(fullFileName); + + ex.Message.Should().StartWith($"Could not find folder '{folder}', the only folder that exist is "); } [Fact] diff --git a/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs b/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs index cb03ec6..ae6f2d7 100644 --- a/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs +++ b/Tool/SystemTestingTools/ValueObjects/FileFullPath.cs @@ -18,15 +18,32 @@ public class FileFullPath : StringValueObject public FileFullPath(string value) : base(value) { if (!Path.HasExtension(_value)) _value += ".txt"; + var folder = Path.GetDirectoryName(_value); - if (!Directory.Exists(folder)) throw new ArgumentException($"Could not find folder '{folder}'"); + + CheckFolderExists(folder); + if (!File.Exists(_value)) { var filesCount = Directory.GetFiles(folder).Length; - throw new ArgumentException($"Could not find file '{_value}', but there are {filesCount} other files in the folder {folder}"); + throw new FileNotFoundException($"Could not find file '{_value}', there are {filesCount} other files in the folder {folder}"); } } + private static void CheckFolderExists(string folder) + { + if (Directory.Exists(folder)) return; + + string parentFolder = folder; + do + { + parentFolder = Path.GetDirectoryName(parentFolder); + } while (!Directory.Exists(parentFolder) && !string.IsNullOrEmpty(parentFolder)); + + + throw new DirectoryNotFoundException($"Could not find folder '{folder}', the only folder that exist is '{parentFolder}'"); + } + public string ReadContent() { string content = File.ReadAllText(_value); From 27791a595c6f63555b69d2f7270147b67a06d778 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 17:58:51 +1000 Subject: [PATCH 25/34] adjust folder paths --- .../ComponentTesting/MathHappyTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs b/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs index d01a0cd..7260bc4 100644 --- a/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs +++ b/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs @@ -1,6 +1,7 @@ using FluentAssertions; using FluentAssertions.Execution; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net; using System.Net.Http; @@ -30,10 +31,11 @@ public async Task When_CallingManyWcfMethods_Then_CanPerformMath_Successfully() var client = Fixture.Server.CreateClient(); client.CreateSession(); - var addResponse = ResponseFactory.FromFiddlerLikeResponseFile($"{Fixture.StubsFolder}/MathWcf/Real_Responses/Happy/200_Add.txt"); + + var addResponse = ResponseFactory.FromFiddlerLikeResponseFile(Path.Combine(Fixture.StubsFolder, "MathWcf/Real_Responses/Happy/200_Add.txt")); client.AppendHttpCallStub(HttpMethod.Post, new System.Uri(Url), addResponse, new Dictionary() { { "SOAPAction", @"""http://tempuri.org/Add""" } }); - var minusResponse = ResponseFactory.FromFiddlerLikeResponseFile($"{Fixture.StubsFolder}/MathWcf/Real_Responses/Happy/200_Minus.txt"); + var minusResponse = ResponseFactory.FromFiddlerLikeResponseFile(Path.Combine(Fixture.StubsFolder, "MathWcf/Real_Responses/Happy/200_Minus.txt")); client.AppendHttpCallStub(HttpMethod.Post, new System.Uri(Url), minusResponse, new Dictionary() { { "SOAPAction", @"""http://tempuri.org/Subtract""" } }); // act From 63efd8472e80811c163b715ca7d4d62d4bfb155f Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:01:30 +1000 Subject: [PATCH 26/34] fixing file path --- .../ComponentTesting/MathHappyTests.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs b/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs index 7260bc4..fb6fa8c 100644 --- a/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs +++ b/Examples/MovieProject/MovieProject.Tests/MovieProject.IsolatedTests/ComponentTesting/MathHappyTests.cs @@ -30,12 +30,11 @@ public async Task When_CallingManyWcfMethods_Then_CanPerformMath_Successfully() // arrange var client = Fixture.Server.CreateClient(); client.CreateSession(); - - var addResponse = ResponseFactory.FromFiddlerLikeResponseFile(Path.Combine(Fixture.StubsFolder, "MathWcf/Real_Responses/Happy/200_Add.txt")); + var addResponse = ResponseFactory.FromFiddlerLikeResponseFile($"{Fixture.StubsFolder}/MathWCF/Real_Responses/Happy/200_Add.txt"); client.AppendHttpCallStub(HttpMethod.Post, new System.Uri(Url), addResponse, new Dictionary() { { "SOAPAction", @"""http://tempuri.org/Add""" } }); - var minusResponse = ResponseFactory.FromFiddlerLikeResponseFile(Path.Combine(Fixture.StubsFolder, "MathWcf/Real_Responses/Happy/200_Minus.txt")); + var minusResponse = ResponseFactory.FromFiddlerLikeResponseFile($"{Fixture.StubsFolder}/MathWCF/Real_Responses/Happy/200_Minus.txt"); client.AppendHttpCallStub(HttpMethod.Post, new System.Uri(Url), minusResponse, new Dictionary() { { "SOAPAction", @"""http://tempuri.org/Subtract""" } }); // act From 218f57ac1c318b857f3c6b3e54f011e929a83fb1 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:06:55 +1000 Subject: [PATCH 27/34] another test --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c8b651d..505930f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -57,7 +57,7 @@ jobs: - name: Build run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.Version }} - name: Test - run: dotnet test --no-build --configuration Release --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" + run: dotnet test --no-build --configuration Release --verbosity quiet --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() From 680c7262fd67efca978887b7aa2a415a6f441231 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:10:49 +1000 Subject: [PATCH 28/34] Improving logging is so overwhelming --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 505930f..c03cfcd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -57,7 +57,7 @@ jobs: - name: Build run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.Version }} - name: Test - run: dotnet test --no-build --configuration Release --verbosity quiet --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" + run: dotnet test --no-build --configuration Release --verbosity quiet --consoleLoggerParameters:ErrorsOnly --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() From e735e59714ae6c0a0a8b9270da227a746001b246 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:20:55 +1000 Subject: [PATCH 29/34] improving pipeline --- .github/workflows/pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c03cfcd..a714f60 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -57,13 +57,13 @@ jobs: - name: Build run: dotnet build --no-restore --verbosity m --configuration Release /p:Version=${{ steps.versioner.outputs.Version }} - name: Test - run: dotnet test --no-build --configuration Release --verbosity quiet --consoleLoggerParameters:ErrorsOnly --logger "trx;LogFileName=test-results.trx" --results-directory "TestResults" + run: dotnet test --no-build --configuration Release --verbosity quiet --logger "trx" --results-directory "TestResults" - name: Test Report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Tests Report - path: TestResults/test-results.trx + name: Tests Reports + path: TestResults reporter: dotnet-trx - name: Copy generated nuget file run: find . -name "SystemTestingTools*.nupkg" -exec cp "{}" ./ \; From ef268dc3a6da539ecae187a2c45f01b3d83ae900 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:22:15 +1000 Subject: [PATCH 30/34] again --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a714f60..f717755 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -63,7 +63,7 @@ jobs: if: success() || failure() with: name: Tests Reports - path: TestResults + path: TestResults/* reporter: dotnet-trx - name: Copy generated nuget file run: find . -name "SystemTestingTools*.nupkg" -exec cp "{}" ./ \; From 90381066156770c35d283f54076ce23f128de61f Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 18:31:07 +1000 Subject: [PATCH 31/34] another --- Tool/SystemTestingTools/Internal/RecordingManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Tool/SystemTestingTools/Internal/RecordingManager.cs b/Tool/SystemTestingTools/Internal/RecordingManager.cs index bac7d95..f4d4f16 100644 --- a/Tool/SystemTestingTools/Internal/RecordingManager.cs +++ b/Tool/SystemTestingTools/Internal/RecordingManager.cs @@ -62,6 +62,7 @@ public List GetRecordings(FolderAbsolutePath folder) recording.File = StandardizeFileNameForDisplay(folder, fullFilePath); list.Add(recording); } + list = list.OrderBy(c => c.File).ToList(); // we sort so it's the same order in windows and linux, so we can more easily test it return list; } From 11f4cfc731fc9480438da40507576a1e826123a0 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 19:11:11 +1000 Subject: [PATCH 32/34] Updating tests to work well with ubuntu --- .../GetMovieTests.cs | 11 ++++++++--- .../RecordingManagerTests.cs | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs index a0cde78..b3ea0b9 100644 --- a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs +++ b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs @@ -88,17 +88,22 @@ public async Task When_UserAsksForMovie_ButWrongUrl_AndNoRecordingFound_Then_Ret using (new AssertionScope()) { // assert logs - string errorMessage = "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=gibberish received exception [No such host is known.]"; + + string errorMessageWindows = "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=gibberish received exception [No such host is known.]"; // windows error message + string errorMessageUbuntu = "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=gibberish received exception [Name or service not known]"; // ubuntu error message + var logs = client.GetSessionLogs(); logs.Should().HaveCount(1); - logs[0].ToString().Should().Be($"Error: {errorMessage}"); + logs[0].ToString().Should().BeOneOf($"Error: {errorMessageWindows}", $"Error: {errorMessageUbuntu}"); // assert outgoing AssertOutgoingRequests(client); // assert return httpResponse.StatusCode.Should().Be(HttpStatusCode.OK); - httpResponse.GetHeaderValue("SystemTestingToolsStub").Should().Be($@"Recording [omdb/pre-approved/happy/last_fallback] reason {errorMessage} and could not find better match"); + httpResponse.GetHeaderValue("SystemTestingToolsStub").Should() + .BeOneOf($@"Recording [omdb/pre-approved/happy/last_fallback] reason {errorMessageWindows} and could not find better match", + $@"Recording [omdb/pre-approved/happy/last_fallback] reason {errorMessageUbuntu} and could not find better match"); var movie = await httpResponse.ReadJsonBody(); movie.Id.Should().Be("tt0123456"); diff --git a/Tool/SystemTestingTools.UnitTests/RecordingManagerTests.cs b/Tool/SystemTestingTools.UnitTests/RecordingManagerTests.cs index a8cfa04..73d4464 100644 --- a/Tool/SystemTestingTools.UnitTests/RecordingManagerTests.cs +++ b/Tool/SystemTestingTools.UnitTests/RecordingManagerTests.cs @@ -120,8 +120,8 @@ public async Task GetRecordings_Including_Old_One_And_ResendAndUpdate_Works() // asserts recordings.Count.Should().Be(3); - recordings[0].File.Should().Be(@"happy/200_ContainsSomeFields_PacificChallenge"); - recordings[0].FileFullPath.Should().EndWith(@"recordings_temp\happy\200_ContainsSomeFields_PacificChallenge.txt"); + recordings[0].File.Should().Be(@"happy/200_ContainsSomeFields_PacificChallenge"); + recordings[0].FileFullPath.Should().EndWith(Path.Combine("recordings_temp","happy","200_ContainsSomeFields_PacificChallenge.txt")); await AssertHappyRecording(recordings[1]); await AssertUnhappyRecording(recordings[2]); From 62db48c52b7037c20ed317b00821419605c00ad3 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 19:19:14 +1000 Subject: [PATCH 33/34] more --- .../GetMovieTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs index b3ea0b9..5ab95a3 100644 --- a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs +++ b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs @@ -27,7 +27,10 @@ public async Task When_UserAsksForMovie_ButWrongUrl_Then_FindResponseInPreApprov // arrange var client = Fixture.Server.CreateClient(); client.CreateSession(); - string errorMessage = "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=matrix received exception [No such host is known.]"; + + var possibleErrorMessages = new string[] { "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=matrix received exception [No such host is known.]", // windows + "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=gibberish received exception [Name or service not known]" }; // ubuntu + // act var httpResponse = await client.GetAsync("/api/movie/matrix"); @@ -37,7 +40,7 @@ public async Task When_UserAsksForMovie_ButWrongUrl_Then_FindResponseInPreApprov // assert logs var logs = client.GetSessionLogs(); logs.Should().HaveCount(1); - logs[0].ToString().Should().Be($"Error: {errorMessage}"); + logs[0].ToString().Should().StartWith($"Error: ").And.ContainAny(possibleErrorMessages); // assert outgoing AssertOutgoingRequests(client); @@ -66,7 +69,7 @@ async Task CheckResponse() { // assert return httpResponse.StatusCode.Should().Be(HttpStatusCode.OK); - httpResponse.GetHeaderValue("SystemTestingToolsStub").Should().Be($@"Recording [omdb/pre-approved/happy/matrix] reason {errorMessage}"); + httpResponse.GetHeaderValue("SystemTestingToolsStub").Should().StartWith($@"Recording [omdb/pre-approved/happy/matrix] reason ").And.ContainAny(possibleErrorMessages); var movie = await httpResponse.ReadJsonBody(); movie.Id.Should().Be("tt0133093"); From 325b99e2d531ba1717f1ef0e918c2c730903cc41 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 19:25:48 +1000 Subject: [PATCH 34/34] one more --- .../MovieProject.InterceptionUnhappyTests/GetMovieTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs index 5ab95a3..27d9190 100644 --- a/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs +++ b/Examples/MovieProject/MovieProject.Tests/MovieProject.InterceptionUnhappyTests/GetMovieTests.cs @@ -29,7 +29,7 @@ public async Task When_UserAsksForMovie_ButWrongUrl_Then_FindResponseInPreApprov client.CreateSession(); var possibleErrorMessages = new string[] { "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=matrix received exception [No such host is known.]", // windows - "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=gibberish received exception [Name or service not known]" }; // ubuntu + "GET http://www.omdbapifake.com/?apikey=863d6589&type=movie&t=matrix received exception [Name or service not known]" }; // ubuntu // act