From ebdb79cf1d5464a6d3c87dbf76c9121770f62dbd Mon Sep 17 00:00:00 2001 From: David Wambugu Date: Mon, 9 Sep 2024 21:11:08 +0300 Subject: [PATCH] Add fix for older dotnet versions which are failing in the tests. --- .../MessageWriterConcurrencyTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/FunctionalTests/Microsoft.OData.Core.Tests/MessageWriterConcurrencyTests.cs b/test/FunctionalTests/Microsoft.OData.Core.Tests/MessageWriterConcurrencyTests.cs index e5818e7018..0b99c28ca9 100644 --- a/test/FunctionalTests/Microsoft.OData.Core.Tests/MessageWriterConcurrencyTests.cs +++ b/test/FunctionalTests/Microsoft.OData.Core.Tests/MessageWriterConcurrencyTests.cs @@ -28,6 +28,7 @@ public async Task VerifyConcurrentResultsAreConsistentAsync() services.AddDefaultODataServices(); ServiceProvider serviceProvider = services.BuildServiceProvider(); + await Task.CompletedTask; // Added due to dotnet < 5 as async await cannot be used only in a loop var content1 = string.Concat(Enumerable.Repeat('A', 1000_000)); var content2 = string.Concat(Enumerable.Repeat('B', 1000_000)); for (int i = 0; i < 1000; i++) @@ -54,13 +55,16 @@ private async Task WritePayload(string content, IServiceProvider service var message = new ODataMessage(outputStream, serviceProvider); await using ODataMessageWriter writer = new ODataMessageWriter(message); + await Task.Yield(); await writer.WriteValueAsync(content); outputStream.Position = 0; using var reader = new StreamReader(outputStream); + await Task.Yield(); + string writen = await reader.ReadToEndAsync(); await writer.DisposeAsync(); return writen;