mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
* Fix WithProbability logic * . * FIX * Update src/WireMock.Net.Minimal/Owin/MappingMatcher.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using WireMock.RequestBuilders;
|
|
using WireMock.ResponseBuilders;
|
|
using WireMock.Server;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests;
|
|
|
|
public partial class WireMockServerTests
|
|
{
|
|
[Fact]
|
|
public async Task WireMockServer_WithProbability()
|
|
{
|
|
// Arrange
|
|
var server = WireMockServer.Start();
|
|
server
|
|
.Given(Request.Create().UsingGet().WithPath("/foo"))
|
|
.WithProbability(0.5)
|
|
.RespondWith(Response.Create().WithStatusCode(200));
|
|
|
|
server
|
|
.Given(Request.Create().UsingGet().WithPath("/foo"))
|
|
.RespondWith(Response.Create().WithStatusCode(500));
|
|
|
|
// Act
|
|
var requestUri = new Uri($"http://localhost:{server.Port}/foo");
|
|
var response = await server.CreateClient().GetAsync(requestUri).ConfigureAwait(false);
|
|
|
|
// Assert
|
|
Assert.Contains(response.StatusCode, [HttpStatusCode.OK, HttpStatusCode.InternalServerError]);
|
|
|
|
server.Stop();
|
|
}
|
|
} |