Adding unit tests, refactoring file access to a service, adding CatalogImageMissingException.

This commit is contained in:
Steve Smith
2017-04-28 19:56:32 -04:00
parent ac89e73bf4
commit 5dbbc4c791
10 changed files with 157 additions and 14 deletions

View File

@@ -0,0 +1,22 @@
using ApplicationCore.Interfaces;
using Microsoft.AspNetCore.Hosting;
using System.IO;
namespace Infrastructure.FileSystem
{
public class LocalFileImageService : IImageService
{
private readonly IHostingEnvironment _env;
public LocalFileImageService(IHostingEnvironment env)
{
_env = env;
}
public byte[] GetImageBytesById(int id)
{
var contentRoot = _env.ContentRootPath + "//Pics";
var path = Path.Combine(contentRoot, id + ".png");
return File.ReadAllBytes(path);
}
}
}

View File

@@ -14,5 +14,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
<PackageReference Include="StructureMap.Microsoft.DependencyInjection" Version="1.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" />
</ItemGroup>
</Project>