Esempio n. 1
0
        public async Task Sync_Folder()
        {
            var sync = new Synchronize(new AppSettings
            {
                DatabaseType = AppSettings.DatabaseTypeList.InMemoryDatabase
            },
                                       new FakeIQuery(),
                                       new FakeSelectorStorage(new FakeIStorage(new List <string> {
                "/"
            },
                                                                                new List <string> {
                "/test.jpg"
            },
                                                                                new List <byte[]>
            {
                CreateAnImage.Bytes
            })), new FakeIWebLogger(), new FakeMemoryCache());

            var result = await sync.Sync("/");

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(FileIndexItem.ExifStatus.Ok, result[0].Status);
            Assert.AreEqual(FileIndexItem.ExifStatus.Ok, result[1].Status);
            Assert.AreEqual("/test.jpg", result[0].FilePath);
            Assert.AreEqual("/", result[1].FilePath);
        }
Esempio n. 2
0
        public async Task Sync_NotFound()
        {
            var sync   = new Synchronize(_appSettings, new FakeIQuery(), new FakeSelectorStorage(), new FakeIWebLogger(), new FakeMemoryCache());
            var result = await sync.Sync("/not_found.jpg");

            Assert.AreEqual(FileIndexItem.ExifStatus.NotFoundNotInIndex, result[0].Status);
        }
Esempio n. 3
0
        public async Task Sync_File()
        {
            var sync = new Synchronize(new AppSettings(), new FakeIQuery(),
                                       new FakeSelectorStorage(new FakeIStorage(new List <string> {
                "/"
            },
                                                                                new List <string> {
                "/test.jpg"
            })), new FakeIWebLogger(), new FakeMemoryCache());

            var result = await sync.Sync("/test.jpg");

            // is missing actual bytes
            Assert.AreEqual(FileIndexItem.ExifStatus.OperationNotSupported, result[0].Status);
        }
Esempio n. 4
0
        public async Task Sync_TempFile_DS_Store()
        {
            var sync = new Synchronize(new AppSettings(), new FakeIQuery(),
                                       new FakeSelectorStorage(new FakeIStorage(new List <string> {
                "/"
            },
                                                                                new List <string> {
                "/test.jpg"
            },
                                                                                new List <byte[]>
            {
                CreateAnImage.Bytes
            })), new FakeIWebLogger(), new FakeMemoryCache());

            var dsStore = await sync.Sync("/.DS_Store");

            Assert.AreEqual(FileIndexItem.ExifStatus.OperationNotSupported, dsStore[0].Status);
        }
Esempio n. 5
0
        public async Task ExistingItem()
        {
            await _query.AddItemAsync(new FileIndexItem(_createAnImage.DbPath)
            {
                Size     = 9998,
                FileHash = "INKV4BSQ54PIAIS5XUFAKBUW5Y"
            });


            var stopWatch = new Stopwatch();

            stopWatch.Start();

            var sync   = new Synchronize(_appSettings, _query, new FakeSelectorStorage(_iStorage), new FakeIWebLogger(), _memoryCache);
            var result = await sync.Sync("/");

            stopWatch.Stop();
            var ts          = stopWatch.Elapsed;
            var elapsedTime = $"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}";

            Console.WriteLine("RunTime " + elapsedTime);

            Assert.IsNotNull(result);
        }