From 62db48c52b7037c20ed317b00821419605c00ad3 Mon Sep 17 00:00:00 2001 From: Alan Sarli Date: Tue, 28 May 2024 19:19:14 +1000 Subject: [PATCH] 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");