mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-11 11:47:12 +02:00
* Version 2.x * Setup .NET 9 * 12 * cleanup some #if for NETSTANDARD1_3 * cleanup + fix tests for net8 * openapi * NO ConfigureAwait(false) + cleanup * . * #endif * HashSet * WireMock.Net.NUnit * HttpContext * Add WebSockets (#1423) * Add WebSockets * Add tests * fix * more tests * Add tests * ... * remove IOwin * - * tests * fluent * ok * match * . * byte[] * x * func * func * byte * trans * ... * frameworks......... * jmes * xxx * sc * using var httpClient = new HttpClient(); * usings * maxRetries * up * xunit v3 * ct * --- * ct * ct2 * T Unit * WireMock.Net.TUnitTests / 10 * t unit first * --project * no tunit * t2 * --project * --project * ci - --project * publish ./test/wiremock-coverage.xml * windows * . * log * ... * log * goed * BodyType * . * . * --scenario * ... * pact * ct * . * WireMock.Net.RestClient.AwesomeAssertions (#1427) * WireMock.Net.RestClient.AwesomeAssertions * ok * atpath * fix test * sonar fixes * ports * proxy test * FIX? * --- * await Task.Delay(100, _ct); * ? * --project * Aspire: use IDistributedApplicationEventingSubscriber (#1428) * broadcast * ok * more tsts * . * Collection * up * . * 2 * remove nfluent * <VersionPrefix>2.0.0-preview-02</VersionPrefix> * ... * . * nuget icon * . * <PackageReference Include="JmesPath.Net" Version="1.1.0" /> * x * 500 * . * fix some warnings * ws
119 lines
4.5 KiB
C#
119 lines
4.5 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
namespace WireMock.Handlers;
|
|
|
|
/// <summary>
|
|
/// Handler to interact with the file system to handle folders and read and write (static mapping) files.
|
|
/// </summary>
|
|
public interface IFileSystemHandler
|
|
{
|
|
/// <summary>
|
|
/// Gets the folder where the static mappings are located. For local file system, this would be `{CurrentFolder}/__admin/mappings`.
|
|
/// </summary>
|
|
/// <returns>The folder name.</returns>
|
|
string GetMappingFolder();
|
|
|
|
/// <summary>
|
|
/// Determines whether the given path refers to an existing directory on disk.
|
|
/// </summary>
|
|
/// <param name="path">The path.</param>
|
|
/// <returns>true if path refers to an existing directory; false if the directory does not exist or an error occurs when trying to determine if the specified directory exists.</returns>
|
|
bool FolderExists(string path);
|
|
|
|
/// <summary>
|
|
/// Creates all directories and subdirectories in the specified path unless they already exist.
|
|
/// </summary>
|
|
/// <param name="path">The path.</param>
|
|
void CreateFolder(string path);
|
|
|
|
/// <summary>
|
|
/// Returns an enumerable collection of file names in a specified path.
|
|
/// </summary>
|
|
/// <param name="path">The path.</param>
|
|
/// <param name="includeSubdirectories">A value indicating whether subdirectories should also be included when enumerating files.</param>
|
|
/// <returns>An enumerable collection of the full names (including paths) for the files in the directory (and optionally subdirectories) specified by path.</returns>
|
|
IEnumerable<string> EnumerateFiles(string path, bool includeSubdirectories);
|
|
|
|
/// <summary>
|
|
/// Read a static mapping file as text.
|
|
/// </summary>
|
|
/// <param name="path">The path (folder + filename with .json extension).</param>
|
|
/// <returns>The file content as text.</returns>
|
|
string ReadMappingFile(string path);
|
|
|
|
/// <summary>
|
|
/// Write the static mapping file.
|
|
/// </summary>
|
|
/// <param name="path">The path (folder + filename with .json extension).</param>
|
|
/// <param name="text">The text.</param>
|
|
void WriteMappingFile(string path, string text);
|
|
|
|
/// <summary>
|
|
/// Read a response body file as byte[].
|
|
/// </summary>
|
|
/// <param name="path">The path or filename from the file to read.</param>
|
|
/// <returns>The file content as bytes.</returns>
|
|
byte[] ReadResponseBodyAsFile(string path);
|
|
|
|
/// <summary>
|
|
/// Read a response body file as text.
|
|
/// </summary>
|
|
/// <param name="path">The path or filename from the file to read.</param>
|
|
/// <returns>The file content as text.</returns>
|
|
string ReadResponseBodyAsString(string path);
|
|
|
|
/// <summary>
|
|
/// Delete a file.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
void DeleteFile(string filename);
|
|
|
|
/// <summary>
|
|
/// Determines whether the given path refers to an existing file on disk.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <returns>true if path refers to an existing file; false if the file does not exist.</returns>
|
|
bool FileExists(string filename);
|
|
|
|
/// <summary>
|
|
/// Write a file.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <param name="bytes">The bytes.</param>
|
|
void WriteFile(string filename, byte[] bytes);
|
|
|
|
/// <summary>
|
|
/// Write a file.
|
|
/// </summary>
|
|
/// <param name="folder">The folder.</param>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <param name="bytes">The bytes.</param>
|
|
void WriteFile(string folder, string filename, byte[] bytes);
|
|
|
|
/// <summary>
|
|
/// Read a file as bytes.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <returns>The file content as bytes.</returns>
|
|
byte[] ReadFile(string filename);
|
|
|
|
/// <summary>
|
|
/// Read a file as string.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <returns>The file content as a string.</returns>
|
|
string ReadFileAsString(string filename);
|
|
|
|
/// <summary>
|
|
/// Gets the folder where the unmatched requests should be stored. For local file system, this would be `{CurrentFolder}/requests/unmatched`.
|
|
/// </summary>
|
|
/// <returns>The folder name.</returns>
|
|
string GetUnmatchedRequestsFolder();
|
|
|
|
/// <summary>
|
|
/// Write an unmatched request to the Unmatched RequestsFolder.
|
|
/// </summary>
|
|
/// <param name="filename">The filename.</param>
|
|
/// <param name="text">The text.</param>
|
|
void WriteUnmatchedRequest(string filename, string text);
|
|
} |