public async Task ExifToolCmdHelper_TestForFakeExifToolInjection() { var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.dng" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, new List <byte[]> { FakeCreateAn.CreateAnImage.Bytes }); var readMeta = new ReadMeta(storage); var fakeExifTool = new FakeExifTool(storage, _appSettings); await new ExifCopy(storage, storage, fakeExifTool, readMeta).XmpSync("/test.dng"); Assert.AreEqual(true, storage.ExistFile("/test.xmp")); var xmpContentReadStream = storage.ReadStream("/test.xmp"); var xmpContent = await new PlainTextFileHelper().StreamToStringAsync(xmpContentReadStream); // Those values are injected by fakeExifTool Assert.AreEqual(true, xmpContent.Contains("<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 11.30'>")); Assert.AreEqual(true, xmpContent.Contains("<rdf:li>test</rdf:li>")); }
public void ExifToolCmdHelper_Update_UpdateLocationAltitudeCommandTest() { var updateModel = new FileIndexItem { LocationAltitude = -41, }; var comparedNames = new List <string> { nameof(FileIndexItem.LocationAltitude).ToLowerInvariant(), }; var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.jpg" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, null); var fakeExifTool = new FakeExifTool(storage, _appSettings); var helperResult = new ExifToolCmdHelper(fakeExifTool, storage, storage, new FakeReadMeta()).Update(updateModel, inputSubPaths, comparedNames); Assert.AreEqual(true, helperResult.Contains("-GPSAltitude=\"-41")); Assert.AreEqual(true, helperResult.Contains("gpsaltituderef#=\"1")); }
public async Task UpdateAsync_ShouldUpdate_IncludeFileHash() { var updateModel = new FileIndexItem { Tags = "tags", Description = "Description", FileHash = "_hash_test" // < - - - - include here }; var comparedNames = new List <string> { nameof(FileIndexItem.Tags).ToLowerInvariant(), nameof(FileIndexItem.Description).ToLowerInvariant(), }; var storage = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg" }, new List <byte[]>()); var fakeExifTool = new FakeExifTool(storage, _appSettings); var helperResult = (await new ExifToolCmdHelper(fakeExifTool, storage, storage, new FakeReadMeta()).UpdateAsync(updateModel, comparedNames, true)); Assert.IsTrue(helperResult.Item1.Contains("tags")); Assert.IsTrue(helperResult.Item1.Contains("Description")); }
public void ExifToolCmdHelper_UpdateTest() { var updateModel = new FileIndexItem { Tags = "tags", Description = "Description", Latitude = 52, Longitude = 3, LocationAltitude = 41, LocationCity = "LocationCity", LocationState = "LocationState", LocationCountry = "LocationCountry", Title = "Title", ColorClass = ColorClassParser.Color.Trash, Orientation = FileIndexItem.Rotation.Rotate90Cw, DateTime = DateTime.Now, }; var comparedNames = new List <string> { nameof(FileIndexItem.Tags).ToLowerInvariant(), nameof(FileIndexItem.Description).ToLowerInvariant(), nameof(FileIndexItem.Latitude).ToLowerInvariant(), nameof(FileIndexItem.Longitude).ToLowerInvariant(), nameof(FileIndexItem.LocationAltitude).ToLowerInvariant(), nameof(FileIndexItem.LocationCity).ToLowerInvariant(), nameof(FileIndexItem.LocationState).ToLowerInvariant(), nameof(FileIndexItem.LocationCountry).ToLowerInvariant(), nameof(FileIndexItem.Title).ToLowerInvariant(), nameof(FileIndexItem.ColorClass).ToLowerInvariant(), nameof(FileIndexItem.Orientation).ToLowerInvariant(), nameof(FileIndexItem.DateTime).ToLowerInvariant(), }; var inputSubPaths = new List <string> { "/test.jpg" }; var storage = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg" }, new List <byte[]>()); var fakeExifTool = new FakeExifTool(storage, _appSettings); var helperResult = new ExifToolCmdHelper(fakeExifTool, storage, storage, new FakeReadMeta()).Update(updateModel, inputSubPaths, comparedNames); Assert.AreEqual(true, helperResult.Contains(updateModel.Tags)); Assert.AreEqual(true, helperResult.Contains(updateModel.Description)); Assert.AreEqual(true, helperResult.Contains(updateModel.Latitude.ToString(CultureInfo.InvariantCulture))); Assert.AreEqual(true, helperResult.Contains(updateModel.Longitude.ToString(CultureInfo.InvariantCulture))); Assert.AreEqual(true, helperResult.Contains(updateModel.LocationAltitude.ToString(CultureInfo.InvariantCulture))); Assert.AreEqual(true, helperResult.Contains(updateModel.LocationCity)); Assert.AreEqual(true, helperResult.Contains(updateModel.LocationState)); Assert.AreEqual(true, helperResult.Contains(updateModel.LocationCountry)); Assert.AreEqual(true, helperResult.Contains(updateModel.Title)); }
public async Task ExifToolCmdHelper_XmpSync() { var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.dng" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, new List <byte[]> { FakeCreateAn.CreateAnImage.Bytes }); var fakeReadMeta = new ReadMeta(storage); var fakeExifTool = new FakeExifTool(storage, _appSettings); var helperResult = await new ExifCopy(storage, storage, fakeExifTool, fakeReadMeta).XmpSync("/test.dng"); Assert.AreEqual("/test.xmp", helperResult); }
public async Task ExifToolCmdHelper_CopyExifPublish() { var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.jpg" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, new List <byte[]> { FakeCreateAn.CreateAnImage.Bytes }); var fakeReadMeta = new ReadMeta(storage); var fakeExifTool = new FakeExifTool(storage, _appSettings); var helperResult = await new ExifCopy(storage, storage, fakeExifTool, fakeReadMeta).CopyExifPublish("/test.jpg", "/test2"); Assert.AreEqual(true, helperResult.Contains("HistorySoftwareAgent")); }
public void ExifToolCmdHelper_XmpCreate() { var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.dng" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, new List <byte[]> { FakeCreateAn.CreateAnImage.Bytes }); var fakeReadMeta = new ReadMeta(storage); var fakeExifTool = new FakeExifTool(storage, _appSettings); new ExifCopy(storage, storage, fakeExifTool, fakeReadMeta).XmpCreate("/test.xmp"); var result = new PlainTextFileHelper().StreamToString(storage.ReadStream("/test.xmp")); Assert.AreEqual("<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Starsky'>\n" + "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n</rdf:RDF>\n</x:xmpmeta>", result); }
public async Task CreateXmpFileIsNotExist_CreateFile_dng() { var updateModel = new FileIndexItem { LocationAltitude = -41, }; var folderPaths = new List <string> { "/" }; var inputSubPaths = new List <string> { "/test.dng" }; var storage = new FakeIStorage(folderPaths, inputSubPaths, null); var fakeExifTool = new FakeExifTool(storage, _appSettings); await new ExifToolCmdHelper(fakeExifTool, storage, storage, new FakeReadMeta()).CreateXmpFileIsNotExist(updateModel, inputSubPaths); Assert.IsTrue(storage.ExistFile("/test.xmp")); }
public MetaUpdateServiceTest() { var provider = new ServiceCollection() .AddMemoryCache() .BuildServiceProvider(); _memoryCache = provider.GetService <IMemoryCache>(); var builder = new DbContextOptionsBuilder <ApplicationDbContext>(); builder.UseInMemoryDatabase(nameof(MetaUpdateService)); var options = builder.Options; var dbContext = new ApplicationDbContext(options); _query = new Query(dbContext, new AppSettings(), null, null, _memoryCache); _queryWithoutCache = new Query(dbContext, new AppSettings { AddMemoryCache = false }, null, new FakeIWebLogger(), null); _appSettings = new AppSettings(); _iStorageFake = new FakeIStorage(new List <string> { "/" }, new List <string> { "/test.jpg", _exampleHash, "/test_default.jpg" }, new List <byte[]> { FakeCreateAn.CreateAnImageNoExif.Bytes }); _exifTool = new FakeExifTool(_iStorageFake, _appSettings); _exampleHash = new FileHash(_iStorageFake).GetHashCode("/test.jpg").Key; _readMeta = new ReadMeta(_iStorageFake, _appSettings, _memoryCache); }