mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Set description when converting MappingModel to IRespondWithAProvider (#1317)
Adding a mapping with a description to `WireMockServer.WithMapping` did not include the description to the resulting `IRespondWithAProvider`, which means that calling `WireMockServer.SavePact` does not populate the description in the contract file. This PR includes the description when mapping from `MappingModel` to `IRespondWithAProvider`.
This commit is contained in:
@@ -76,6 +76,11 @@ public partial class WireMockServer
|
||||
respondProvider = respondProvider.WithTitle(mappingModel.Title!);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(mappingModel.Description))
|
||||
{
|
||||
respondProvider = respondProvider.WithDescription(mappingModel.Description!);
|
||||
}
|
||||
|
||||
if (mappingModel.Priority != null)
|
||||
{
|
||||
respondProvider = respondProvider.AtPriority(mappingModel.Priority.Value);
|
||||
|
||||
@@ -62,13 +62,15 @@ public partial class WireMockAdminApiTests
|
||||
{
|
||||
Request = new RequestModel { Path = "/1" },
|
||||
Response = new ResponseModel { Body = "txt 1" },
|
||||
Title = "test 1"
|
||||
Title = "test 1",
|
||||
Description = "description 1"
|
||||
};
|
||||
var model2 = new MappingModel
|
||||
{
|
||||
Request = new RequestModel { Path = "/2" },
|
||||
Response = new ResponseModel { Body = "txt 2" },
|
||||
Title = "test 2"
|
||||
Title = "test 2",
|
||||
Description = "description 2"
|
||||
};
|
||||
var result = await api.PostMappingsAsync(new[] { model1, model2 }).ConfigureAwait(false);
|
||||
|
||||
@@ -77,6 +79,8 @@ public partial class WireMockAdminApiTests
|
||||
Check.That(result.Status).IsNotNull();
|
||||
Check.That(result.Guid).IsNull();
|
||||
Check.That(server.Mappings.Where(m => !m.IsAdminInterface)).HasSize(2);
|
||||
Check.That(server.Mappings.Single(x => x.Title == "test 1").Description).IsEqualTo("description 1");
|
||||
Check.That(server.Mappings.Single(x => x.Title == "test 2").Description).IsEqualTo("description 2");
|
||||
|
||||
server.Stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user