mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-09 01:14:07 +02:00
FIX?
This commit is contained in:
@@ -7,16 +7,29 @@ namespace WireMock.WebSockets;
|
||||
|
||||
internal class WebSocketMessageBuilder : IWebSocketMessageBuilder
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string? MessageText { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public byte[]? MessageBytes { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public TimeSpan? Delay { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public WebSocketMessageType Type { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ShouldClose { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder WithEcho()
|
||||
{
|
||||
Type = WebSocketMessageType.Close;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder WithText(string text)
|
||||
{
|
||||
MessageText = Guard.NotNull(text);
|
||||
@@ -24,6 +37,7 @@ internal class WebSocketMessageBuilder : IWebSocketMessageBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder WithBinary(byte[] bytes)
|
||||
{
|
||||
MessageBytes = Guard.NotNull(bytes);
|
||||
@@ -31,23 +45,27 @@ internal class WebSocketMessageBuilder : IWebSocketMessageBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder WithDelay(TimeSpan delay)
|
||||
{
|
||||
Delay = delay;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder WithDelay(int delayInMilliseconds)
|
||||
{
|
||||
Guard.Condition(delayInMilliseconds, d => d >= 0);
|
||||
return WithDelay(TimeSpan.FromMilliseconds(delayInMilliseconds));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder Close()
|
||||
{
|
||||
ShouldClose = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IWebSocketMessageBuilder AndClose() => Close();
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Types;
|
||||
|
||||
namespace WireMock.WebSockets;
|
||||
|
||||
|
||||
@@ -9,6 +9,12 @@ namespace WireMock.WebSockets;
|
||||
/// </summary>
|
||||
public interface IWebSocketMessageBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Echo all received messages back to client
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
IWebSocketMessageBuilder WithEcho();
|
||||
|
||||
/// <summary>
|
||||
/// Send a specific text message
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user