mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 10:18:26 +02:00
Add a new stub mapping
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using WireMock.Matchers.Request;
|
||||
using System;
|
||||
using WireMock.Matchers.Request;
|
||||
|
||||
namespace WireMock.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// The respond with a provider.
|
||||
/// </summary>
|
||||
internal class RespondWithAProvider : IRespondWithAProvider
|
||||
internal class RespondWithAProvider : IRespondWithAProviderGuid
|
||||
{
|
||||
private Guid? _guid;
|
||||
|
||||
/// <summary>
|
||||
/// The _registration callback.
|
||||
/// </summary>
|
||||
@@ -36,7 +39,20 @@ namespace WireMock.Server
|
||||
/// </param>
|
||||
public void RespondWith(IResponseProvider provider)
|
||||
{
|
||||
_registrationCallback(new Mapping(_requestMatcher, provider));
|
||||
var mappingGuid = _guid ?? Guid.NewGuid();
|
||||
_registrationCallback(new Mapping(mappingGuid, _requestMatcher, provider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Define a unique identifier for this mapping.
|
||||
/// </summary>
|
||||
/// <param name="guid">The unique identifier.</param>
|
||||
/// <returns>The <see cref="IRespondWithAProviderGuid"/>.</returns>
|
||||
public IRespondWithAProviderGuid WithGuid(Guid guid)
|
||||
{
|
||||
_guid = guid;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user