mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-18 00:07:41 +01:00
* Add WireMock.Net.AspNetCore.Middleware * . * WireMock.Net.Middleware.Tests * . * X-WireMock-Response-Delay
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using Stef.Validation;
|
|
using WireMock.Server;
|
|
using WireMock.Settings;
|
|
|
|
namespace WireMock.Net.AspNetCore.Middleware;
|
|
|
|
/// <summary>
|
|
/// WireMockServer Instance object
|
|
/// </summary>
|
|
internal class WireMockServerInstance
|
|
{
|
|
private readonly Action<WireMockServer> _configureAction;
|
|
private readonly WireMockServerSettings? _settings;
|
|
|
|
/// <summary>
|
|
/// Creates a new instance and provides ability to add configuration
|
|
/// for the start method of <see cref="WireMockServer"/>
|
|
/// </summary>
|
|
public WireMockServerInstance(Action<WireMockServer> configure, WireMockServerSettings? settings = null)
|
|
{
|
|
_configureAction = Guard.NotNull(configure);
|
|
_settings = settings;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Instance accessor for the <see cref="WireMockServer" />
|
|
/// </summary>
|
|
public WireMockServer? Instance { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Configures and starts <see cref="WireMockServer"/> instance for use.
|
|
/// </summary>
|
|
public void Start()
|
|
{
|
|
Instance = _settings != null ? WireMockServer.Start(_settings) : WireMockServer.Start();
|
|
|
|
_configureAction.Invoke(Instance);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stops the <see cref="WireMockServer"/>
|
|
/// </summary>
|
|
public void Stop()
|
|
{
|
|
Instance?.Stop();
|
|
}
|
|
} |