Fix BodyAsFile to also allow relative paths (#244)

* Read only .json files as static mapping files and fix current folder for BodyAsFile

* include .json again

* LocalFileSystemHandler_ReadResponseBodyAsFile_Throws

* Read array from static mappings folder

* xml soap example
This commit is contained in:
Stef Heyenrath
2019-01-19 19:27:48 +01:00
committed by GitHub
parent 34abd05d19
commit d736745aff
24 changed files with 284 additions and 59 deletions

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using System.Collections.Generic;
using System.IO;
using JetBrains.Annotations;
using WireMock.Validation;
namespace WireMock.Handlers
@@ -58,5 +58,15 @@ namespace WireMock.Handlers
File.WriteAllText(path, text);
}
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsFile"/>
public byte[] ReadResponseBodyAsFile(string path)
{
Check.NotNullOrEmpty(path, nameof(path));
// In case the path is a filename, the path will be adjusted to the MappingFolder.
// Else the path will just be as-is.
return File.ReadAllBytes(Path.GetFileName(path) == path ? Path.Combine(GetMappingFolder(), path) : path);
}
}
}