Esempio n. 1
0
        public async Task Importer_Gpx()
        {
            var storage = new FakeIStorage(
                new List <string> {
                "/"
            },
                new List <string> {
                "/test.gpx"
            },
                new List <byte[]> {
                CreateAnGpx.Bytes
            });

            var importService = new Import(new FakeSelectorStorage(storage), _appSettings, new FakeIImportQuery(),
                                           new FakeExifTool(storage, _appSettings), _query, _console, new FakeIMetaExifThumbnailService(), new FakeIWebLogger(), new FakeMemoryCache());
            var expectedFilePath = ImportTest.GetExpectedFilePath(storage, _appSettings, "/test.gpx");

            var result = await importService.Importer(new List <string> {
                "/test.gpx"
            },
                                                      new ImportSettingsModel());

            var getResult = await _query.GetObjectByFilePathAsync(expectedFilePath);

            Assert.IsNotNull(getResult);
            Assert.AreEqual(expectedFilePath, getResult.FilePath);
            Assert.AreEqual(ImportStatus.Ok, result[0].Status);

            await _query.RemoveItemAsync(getResult);
        }
Esempio n. 2
0
        public async Task Importer_HappyFlow_ItShouldAddTo_ImportDb()
        {
            var importService = new Import(new FakeSelectorStorage(_iStorageFake),
                                           _appSettings, _importQuery,
                                           new FakeExifTool(_iStorageFake, _appSettings), _query,
                                           _console, new FakeIMetaExifThumbnailService(),
                                           new FakeIWebLogger());

            var result = await importService.Importer(new List <string> {
                "/test.jpg"
            },
                                                      new ImportSettingsModel {
                Structure = "/yyyy/MM/yyyy_MM_dd*/_yyyyMMdd_HHmmss.ext"
            });

            var isHashInImportDb = await _importQuery.IsHashInImportDbAsync(_exampleHash);

            Assert.IsTrue(isHashInImportDb);

            var expectedFilePath = ImportTest.GetExpectedFilePath(_iStorageFake, new AppSettings
            {
                Structure = "/yyyy/MM/yyyy_MM_dd*/_yyyyMMdd_HHmmss.ext"
            }, "/test.jpg");

            var queryResult = await _query.GetObjectByFilePathAsync(expectedFilePath);

            Assert.IsNotNull(queryResult);

            _iStorageFake.FileDelete(expectedFilePath);
            await _query.RemoveItemAsync(queryResult);
        }
Esempio n. 3
0
        public async Task Importer_OverwriteColorClass()
        {
            var importService = new Import(new FakeSelectorStorage(_iStorageFake),
                                           _appSettings, new FakeIImportQuery(),
                                           new FakeExifTool(_iStorageFake, _appSettings),
                                           _query, _console, new FakeIMetaExifThumbnailService(),
                                           new FakeIWebLogger());

            var expectedFilePath = ImportTest.GetExpectedFilePath(_iStorageFake, _appSettings, "/test.jpg");
            var result           = await importService.Importer(new List <string> {
                "/test.jpg"
            },
                                                                new ImportSettingsModel {
                ColorClass = 5
            });

            Assert.AreEqual(expectedFilePath, result.FirstOrDefault().FilePath);
            var queryResult = await _query.GetObjectByFilePathAsync(expectedFilePath);

            Assert.IsNotNull(queryResult);

            Assert.AreEqual(expectedFilePath, queryResult.FilePath);
            Assert.AreEqual(ColorClassParser.Color.Typical, queryResult.ColorClass);

            _iStorageFake.FileDelete(expectedFilePath);
            await _query.RemoveItemAsync(queryResult);
        }
Esempio n. 4
0
        public async Task Importer_OverwriteStructure_HappyFlow()
        {
            var importService = new Import(new FakeSelectorStorage(_iStorageFake),
                                           _appSettings, new FakeIImportQuery(),
                                           new FakeExifTool(_iStorageFake, _appSettings), _query, _console,
                                           new FakeIMetaExifThumbnailService(), new FakeIWebLogger(), new FakeMemoryCache());

            var result = await importService.Importer(new List <string> {
                "/test.jpg"
            },
                                                      new ImportSettingsModel {
                Structure = "/yyyy/MM/yyyy_MM_dd*/_yyyyMMdd_HHmmss.ext"
            });

            var expectedFilePath = ImportTest.GetExpectedFilePath(_iStorageFake, new AppSettings
            {
                Structure = "/yyyy/MM/yyyy_MM_dd*/_yyyyMMdd_HHmmss.ext"
            }, "/test.jpg");

            Assert.AreEqual(expectedFilePath, result[0].FilePath);
            var queryResult = await _query.GetObjectByFilePathAsync(expectedFilePath);

            Assert.IsNotNull(queryResult);
            Assert.AreEqual(expectedFilePath, queryResult.FilePath);

            _iStorageFake.FileDelete(expectedFilePath);
            await _query.RemoveItemAsync(queryResult);
        }
Esempio n. 5
0
        public async Task Importer_ToDefaultFolderStructure_default_HappyFlow()
        {
            var importService = new Import(new FakeSelectorStorage(_iStorageFake),
                                           _appSettings, new FakeIImportQuery(),
                                           new FakeExifTool(_iStorageFake, _appSettings),
                                           _query, _console, new FakeIMetaExifThumbnailService(),
                                           new FakeIWebLogger());

            var expectedFilePath = ImportTest.GetExpectedFilePath(_iStorageFake, _appSettings, "/test.jpg");
            var result           = await importService.Importer(new List <string> {
                "/test.jpg"
            },
                                                                new ImportSettingsModel());

            Assert.AreEqual(expectedFilePath, result[0].FilePath);
            var queryResult = await _query.GetObjectByFilePathAsync(expectedFilePath);

            Assert.IsNotNull(queryResult);
            Assert.AreEqual(expectedFilePath, queryResult.FilePath);

            _iStorageFake.FileDelete(expectedFilePath);
            await _query.RemoveItemAsync(queryResult);
        }