mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-30 21:04:48 +00:00
test: add multiple mocks for use with testing project
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Crestron.SimplSharp.CrestronWebSocketServer
|
||||
namespace Crestron.SimplSharp.WebScripting
|
||||
{
|
||||
/// <summary>Mock HttpCwsServer class for HTTP web server functionality</summary>
|
||||
public class HttpCwsServer : IDisposable
|
||||
@@ -92,6 +92,13 @@ namespace Crestron.SimplSharp.CrestronWebSocketServer
|
||||
_routes.Remove(route.ToLowerInvariant());
|
||||
}
|
||||
|
||||
/// <summary>Unregisters a route handler</summary>
|
||||
/// <param name="route">Route path to unregister</param>
|
||||
public void Unregister(string route)
|
||||
{
|
||||
RemoveRoute(route);
|
||||
}
|
||||
|
||||
private async Task ProcessRequestsAsync()
|
||||
{
|
||||
while (_listening && _httpListener != null)
|
||||
@@ -243,6 +250,13 @@ namespace Crestron.SimplSharp.CrestronWebSocketServer
|
||||
set => _response.StatusCode = value;
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the status description</summary>
|
||||
public string StatusDescription
|
||||
{
|
||||
get => _response.StatusDescription;
|
||||
set => _response.StatusDescription = value;
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the content type</summary>
|
||||
public string? ContentType
|
||||
{
|
||||
@@ -287,6 +301,19 @@ namespace Crestron.SimplSharp.CrestronWebSocketServer
|
||||
{
|
||||
OutputStream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
/// <summary>Ends the response</summary>
|
||||
public void End()
|
||||
{
|
||||
try
|
||||
{
|
||||
_response.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore exceptions during close
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Interface for HTTP request handlers</summary>
|
||||
|
||||
Reference in New Issue
Block a user