Add MatchOperator "Or", "And" and "Average" for patterns (#755)

* wip

* ...

* .

* ...

* ...

* path

* url

* b

* t

* client

* .

* RequestMessageMethodMatcherTests

* .

* h

* .

* fix tests

* .
This commit is contained in:
Stef Heyenrath
2022-06-09 21:31:54 +02:00
committed by GitHub
parent 1f23022460
commit 0441c1d85e
95 changed files with 5736 additions and 5111 deletions

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using JetBrains.Annotations;
using Newtonsoft.Json;
@@ -12,6 +13,7 @@ using WireMock.Admin.Mappings;
using WireMock.Authentication;
using WireMock.Exceptions;
using WireMock.Handlers;
using WireMock.Http;
using WireMock.Logging;
using WireMock.Matchers.Request;
using WireMock.Owin;
@@ -101,6 +103,43 @@ public partial class WireMockServer : IWireMockServer
}
#endregion
#region HttpClient
/// <summary>
/// Create a <see cref="HttpClient"/> which can be used to call this instance.
/// </summary>
[PublicAPI]
public HttpClient CreateClient()
{
if (!IsStarted)
{
throw new InvalidOperationException("Unable to create HttpClient because the service is not started.");
}
var client = HttpClientFactory2.Create();
client.BaseAddress = new Uri(Url!);
return client;
}
/// <summary>
/// Create <see cref="HttpClient"/>s (one for each URL) which can be used to call this instance.
/// </summary>
[PublicAPI]
public HttpClient[] CreateClients()
{
if (!IsStarted)
{
throw new InvalidOperationException("Unable to create HttpClients because the service is not started.");
}
return Urls.Select(url =>
{
var client = HttpClientFactory2.Create();
client.BaseAddress = new Uri(url);
return client;
}).ToArray();
}
#endregion
#region Start/Stop
/// <summary>
/// Starts this WireMockServer with the specified settings.