Add a new stub mapping

This commit is contained in:
Stef Heyenrath
2017-01-27 21:19:30 +01:00
parent a334974bef
commit 1f33e6a671
28 changed files with 576 additions and 264 deletions

View File

@@ -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;
}
}
}