public void TestGetArchiveTypeFrom(string filePath, string fileName, string extension, string fullExtension, ArchiveType archiveType) { _autoMocker .Setup <IPathService, string>(m => m.GetFileNameWithoutExtension(filePath)) .Returns(fileName); _autoMocker .Setup <IPathService, string>(m => m.GetExtension(filePath)) .Returns(extension); var configuration = new ArchiveTypeMapperConfiguration { ExtensionToArchiveTypeDictionary = new Dictionary <string, ArchiveType> { [fullExtension] = archiveType } }; _autoMocker.Use(configuration); var mapper = _autoMocker.CreateInstance <ArchiveTypeMapper>(); var actualType = mapper.GetArchiveTypeFrom(filePath); Assert.NotNull(actualType); Assert.Equal(archiveType, actualType); }
public ArchiveTypeMapper( IPathService pathService, ArchiveTypeMapperConfiguration configuration) { _pathService = pathService; _configuration = configuration; }
private static void RegisterArchiveTypeMapperConfiguration(IMutableDependencyResolver services, IConfiguration configuration) { var config = new ArchiveTypeMapperConfiguration(); configuration.GetSection("Archive").Bind(config); services.RegisterConstant(config); }