Files
WireMock.Net/test/WireMock.Net.Tests/Handlers/LocalFileSystemHandlerTests.cs
JackCreativeCrew 12444cc11e [265] Add file upload to allow mocking of file operations (#266)
* [265] Add file upload to allow mocking of file operations

* [265] Fix failing test

* Update code + add tests

* LocalFileSystemHandlerTests

* 1.0.13

* Fixed the file post to create the mapping folder if none exists to begin with, otherwise the file upload fails with 404 (can't find the folder to upload to).

* fix tests

* add more tests for LocalFileSystemHandler

* Added the head method for files to check if a file exists without returning it as a body.

* Add a test and fix the response message (head requires no body).

* Fix newline

* Fix newline.

* Fix the number of mapping tests

* Update tests and update client-interface-api

* Cleanup "MappingConverter.cs"
2019-04-11 08:46:14 +02:00

82 lines
2.4 KiB
C#

using NFluent;
using System;
using System.IO;
using WireMock.Handlers;
using Xunit;
namespace WireMock.Net.Tests.Handlers
{
public class LocalFileSystemHandlerTests
{
private readonly LocalFileSystemHandler _sut = new LocalFileSystemHandler();
[Fact]
public void LocalFileSystemHandler_GetMappingFolder()
{
// Act
string result = _sut.GetMappingFolder();
// Assert
Check.That(result).EndsWith(Path.Combine("__admin", "mappings"));
}
[Fact]
public void LocalFileSystemHandler_CreateFolder_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.CreateFolder(null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_WriteMappingFile_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.WriteMappingFile(null, null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_ReadResponseBodyAsFile_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.ReadResponseBodyAsFile(null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_FileExists_ReturnsFalse()
{
// Act
var result = _sut.FileExists("x.x");
// Assert
Check.That(result).IsFalse();
}
[Fact]
public void LocalFileSystemHandler_FileExists_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.FileExists(null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_ReadFile_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.ReadFile(null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_WriteFile_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.WriteFile(null, null)).Throws<ArgumentNullException>();
}
[Fact]
public void LocalFileSystemHandler_DeleteFile_ThrowsArgumentNullException()
{
// Act
Check.ThatCode(() => _sut.DeleteFile(null)).Throws<ArgumentNullException>();
}
}
}