mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 22:33:35 +01:00
* wip * HandlebarsRegistrationCallback * HandlebarsContextFactoryTests * 1.0.21.0 * fix sonar * LocalFileSystemHandler * readme * Fix System.IO.IOException
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using FluentAssertions;
|
|
using Moq;
|
|
using System;
|
|
using WireMock.Handlers;
|
|
using WireMock.Util;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Util
|
|
{
|
|
public class FileHelperTests
|
|
{
|
|
[Fact]
|
|
public void TryReadMappingFileWithRetryAndDelay_WithIFileSystemHandlerOk_ReturnsTrue()
|
|
{
|
|
// Assign
|
|
var staticMappingHandlerMock = new Mock<IFileSystemHandler>();
|
|
staticMappingHandlerMock.Setup(m => m.ReadMappingFile(It.IsAny<string>())).Returns("text");
|
|
|
|
// Act
|
|
bool result = FileHelper.TryReadMappingFileWithRetryAndDelay(staticMappingHandlerMock.Object, @"c:\temp", out string value);
|
|
|
|
// Assert
|
|
result.Should().BeTrue();
|
|
value.Should().Be("text");
|
|
|
|
// Verify
|
|
staticMappingHandlerMock.Verify(m => m.ReadMappingFile(@"c:\temp"), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public void TryReadMappingFileWithRetryAndDelay_WithIFileSystemHandlerThrows_ReturnsFalse()
|
|
{
|
|
// Assign
|
|
var staticMappingHandlerMock = new Mock<IFileSystemHandler>();
|
|
staticMappingHandlerMock.Setup(m => m.ReadMappingFile(It.IsAny<string>())).Throws<NotSupportedException>();
|
|
|
|
// Act
|
|
bool result = FileHelper.TryReadMappingFileWithRetryAndDelay(staticMappingHandlerMock.Object, @"c:\temp", out string value);
|
|
|
|
// Assert
|
|
result.Should().BeFalse();
|
|
value.Should().BeNull();
|
|
|
|
// Verify
|
|
staticMappingHandlerMock.Verify(m => m.ReadMappingFile(@"c:\temp"), Times.Exactly(3));
|
|
}
|
|
}
|
|
}
|