* Fix construction of path in OpenApiParser (#1265)

* Server-Sent Events (#1269)

* Server Side Events

* fixes

* await HandleSseStringAsync(responseMessage, response, bodyData);

* 1.7.5-preview-01

* IBlockingQueue

* 1.7.5-preview-02 (03 April 2025)

* IBlockingQueue

* ...

* Support OpenApi V31 (#1279)

* Support OpenApi V31

* Update src/WireMock.Net.OpenApiParser/Extensions/OpenApiSchemaExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fx

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add ProtoDefinitionHelper.FromDirectory (#1263)

* Add ProtoDefinitionHelper.FromDirectory

* .

* unix-windows

* move test

* imports in the proto files indeed should use a forward slash

* updates

* .

* private Func<IdOrTexts> ProtoDefinitionFunc()

* OpenTelemetry

* .

* fix path utils

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Stef Heyenrath
2025-04-23 11:51:44 +02:00
committed by GitHub
parent fc0f82db33
commit 4368e3cde6
66 changed files with 3275 additions and 1002 deletions

View File

@@ -3,6 +3,7 @@
#if !NET452
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -319,5 +320,62 @@ public partial class WireMockServerTests
server.Stop();
}
[Fact]
public async Task WireMockServer_WithSseBody()
{
// Arrange
var server = WireMockServer.Start();
server
.WhenRequest(r => r
.UsingGet()
.WithPath("/sse")
)
.ThenRespondWith(r => r
.WithHeader("Content-Type", "text/event-stream")
.WithHeader("Cache-Control", "no-cache")
.WithHeader("Connection", "keep-alive")
.WithSseBody(async (_, queue) =>
{
for (var i = 1; i <= 3; i++)
{
queue.Write($"x {i};\r\n");
await Task.Delay(100);
}
queue.Close();
})
);
server
.WhenRequest(r => r
.UsingGet()
)
.ThenRespondWith(r => r
.WithBody("normal")
);
using var client = new HttpClient();
// Act 1
var normal = await new HttpClient()
.GetAsync(server.Url)
.ConfigureAwait(false);
(await normal.Content.ReadAsStringAsync()).Should().Be("normal");
// Act 2
using var response = await client.GetStreamAsync($"{server.Url}/sse");
using var reader = new StreamReader(response);
var data = string.Empty;
while (!reader.EndOfStream)
{
var line = await reader.ReadLineAsync();
data += line;
}
// Assert 2
data.Should().Be("x 1;x 2;x 3;");
}
}
#endif