shoc-backend/SeaHavenIndustries.Tests/TestFileStoragePort.cs

29 lines
720 B
C#
Raw Permalink Normal View History

using Microsoft.AspNetCore.Http;
using SeaHaven.Services.Interfaces;
namespace SeaHavenIndustries.Tests;
internal sealed class TestFileStoragePort : IFileStoragePort
{
private readonly Func<string, Stream?> _openRead;
public TestFileStoragePort(Func<string, Stream?>? openRead = null)
{
_openRead = openRead ?? (_ => null);
}
public int TryDeleteCalls { get; private set; }
public Task<string> SaveFileAsync(IFormFile file)
=> Task.FromResult("https://example.test/Assets/Documents/saved.bin");
public bool TryDelete(string fileUrl)
{
TryDeleteCalls++;
return true;
}
public Stream? OpenRead(string fileUrl)
=> _openRead(fileUrl);
}