mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-26 03:11:56 +01:00
Create WireMock.Net.MimePart project (#1300)
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
63
src/WireMock.Net.Minimal/ResponseMessageBuilder.cs
Normal file
63
src/WireMock.Net.Minimal/ResponseMessageBuilder.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Constants;
|
||||
using WireMock.Http;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
|
||||
namespace WireMock;
|
||||
|
||||
internal static class ResponseMessageBuilder
|
||||
{
|
||||
private static readonly IDictionary<string, WireMockList<string>> ContentTypeJsonHeaders = new Dictionary<string, WireMockList<string>>
|
||||
{
|
||||
{ HttpKnownHeaderNames.ContentType, new WireMockList<string> { WireMockConstants.ContentTypeJson } }
|
||||
};
|
||||
|
||||
internal static ResponseMessage Create(HttpStatusCode statusCode, string? status, Guid? guid = null)
|
||||
{
|
||||
return Create((int)statusCode, status, guid);
|
||||
}
|
||||
|
||||
internal static ResponseMessage Create(int statusCode, string? status, Guid? guid = null)
|
||||
{
|
||||
return Create(statusCode, status, null, guid);
|
||||
}
|
||||
|
||||
internal static ResponseMessage Create(int statusCode, string? status, string? error, Guid? guid = null)
|
||||
{
|
||||
var response = new ResponseMessage
|
||||
{
|
||||
StatusCode = statusCode,
|
||||
Headers = ContentTypeJsonHeaders
|
||||
};
|
||||
|
||||
if (status != null || error != null)
|
||||
{
|
||||
response.BodyData = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.Json,
|
||||
BodyAsJson = new StatusModel
|
||||
{
|
||||
Guid = guid,
|
||||
Status = status,
|
||||
Error = error
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
internal static ResponseMessage Create(HttpStatusCode statusCode)
|
||||
{
|
||||
return new ResponseMessage
|
||||
{
|
||||
StatusCode = statusCode
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user