Пример #1
0
        public async Task Json_Write_Read()
        {
            var fakeStorage    = new FakeIStorage();
            var itemJsonParser = new FileIndexItemJsonParser(fakeStorage);
            await itemJsonParser.WriteAsync(ExampleItem);

            var result = itemJsonParser.Read(new FileIndexItem("/test.jpg"));

            Assert.AreEqual(ExampleItem.Tags, result.Tags);
            Assert.AreEqual(ExampleItem.FileHash, result.FileHash);
            Assert.AreEqual(ExampleItem.IsDirectory, result.IsDirectory);
            Assert.AreEqual(ExampleItem.Description, result.Description);
            Assert.AreEqual(ExampleItem.Title, result.Title);
            Assert.AreEqual(ExampleItem.DateTime, result.DateTime);
            Assert.AreEqual(ExampleItem.AddToDatabase, result.AddToDatabase);
            Assert.AreEqual(ExampleItem.LastEdited, result.LastEdited);
            Assert.AreEqual(ExampleItem.Latitude, result.Latitude);
            Assert.AreEqual(ExampleItem.Longitude, result.Longitude);
            Assert.AreEqual(ExampleItem.LocationAltitude, result.LocationAltitude);
            Assert.AreEqual(ExampleItem.LocationCity, result.LocationCity);
            Assert.AreEqual(ExampleItem.LocationCountry, result.LocationCountry);
            Assert.AreEqual(ExampleItem.LocationState, result.LocationState);
            Assert.AreEqual(ExampleItem.ColorClass, result.ColorClass);
            Assert.AreEqual(ExampleItem.Orientation, result.Orientation);
            Assert.AreEqual(ExampleItem.ImageWidth, result.ImageWidth);
            Assert.AreEqual(ExampleItem.ImageHeight, result.ImageHeight);
            Assert.AreEqual(ExampleItem.ImageFormat, result.ImageFormat);
            Assert.AreEqual(ExampleItem.Aperture, result.Aperture);
            Assert.AreEqual(ExampleItem.ShutterSpeed, result.ShutterSpeed);
            Assert.AreEqual(ExampleItem.IsoSpeed, result.IsoSpeed);
            Assert.AreEqual(ExampleItem.Software, result.Software);
            Assert.AreEqual(ExampleItem.MakeModel, result.MakeModel);
            Assert.AreEqual(ExampleItem.FocalLength, result.FocalLength);
        }
Пример #2
0
        public void ReadTest_FromCopiedText()
        {
            var input =
                "{\n  \"FilePath\": \"/test.jpg\",\n  \"FileName\": \"test.jpg\",\n  \"FileHash\": " +
                "\"Test\",\n  \"FileCollectionName\": \"test\",\n  \"ParentDirectory\": \"/\",\n  " +
                "\"IsDirectory\": false,\n  \"Tags\": \"test\",\n  \"Status\": \"ExifWriteNotSupported\"," +
                "\n  \"Description\": \"Description\",\n  \"Title\": \"Title\",\n  \"DateTime\": " +
                "\"2020-01-01T00:00:00\",\n  \"AddToDatabase\": \"2020-01-01T00:00:00\",\n  \"LastEdited\": " +
                "\"2020-01-01T00:00:00\",\n  \"Latitude\": 50,\n  \"Longitude\": 5,\n  \"LocationAltitude\": 1,\n " +
                " \"LocationCity\": \"LocationCity\",\n  \"LocationState\": \"LocationState\",\n " +
                " \"LocationCountry\": \"LocationCountry\",\n  \"ColorClass\": 2,\n  \"Orientation\": \"Rotate180\",\n " +
                " \"ImageWidth\": 100,\n  \"ImageHeight\": 140,\n  \"ImageFormat\": \"jpg\",\n  \"CollectionPaths\": [],\n" +
                "  \"Aperture\": 1,\n  \"ShutterSpeed\": \"10\",\n  \"IsoSpeed\": 1200,\n  \"Software\": \"starsky\",\n " +
                " \"MakeModel\": \"test|test|\",\n  \"Make\": \"test\",\n  \"Model\": \"test\",\n  \"FocalLength\": 200\n}";

            var fakeStorage = new FakeIStorage();
            var jsonSubPath = "/.starsky." + "test.jpg" + ".json";

            fakeStorage.WriteStream(
                new PlainTextFileHelper().StringToStream(input), jsonSubPath);

            var itemJsonParser = new FileIndexItemJsonParser(fakeStorage);

            var result = itemJsonParser.Read(new FileIndexItem("/test.jpg"));

            Assert.AreEqual(ExampleItem.Tags, result.Tags);
            Assert.AreEqual(ExampleItem.FileHash, result.FileHash);
            Assert.AreEqual(ExampleItem.IsDirectory, result.IsDirectory);
            Assert.AreEqual(ExampleItem.Description, result.Description);
            Assert.AreEqual(ExampleItem.Title, result.Title);
            Assert.AreEqual(ExampleItem.DateTime, result.DateTime);
            Assert.AreEqual(ExampleItem.AddToDatabase, result.AddToDatabase);
            Assert.AreEqual(ExampleItem.LastEdited, result.LastEdited);
            Assert.AreEqual(ExampleItem.Latitude, result.Latitude);
            Assert.AreEqual(ExampleItem.Longitude, result.Longitude);
            Assert.AreEqual(ExampleItem.LocationAltitude, result.LocationAltitude);
            Assert.AreEqual(ExampleItem.LocationCity, result.LocationCity);
            Assert.AreEqual(ExampleItem.LocationCountry, result.LocationCountry);
            Assert.AreEqual(ExampleItem.LocationState, result.LocationState);
            Assert.AreEqual(ExampleItem.ColorClass, result.ColorClass);
            Assert.AreEqual(ExampleItem.Orientation, result.Orientation);
            Assert.AreEqual(ExampleItem.ImageWidth, result.ImageWidth);
            Assert.AreEqual(ExampleItem.ImageHeight, result.ImageHeight);
            Assert.AreEqual(ExampleItem.ImageFormat, result.ImageFormat);
            Assert.AreEqual(ExampleItem.Aperture, result.Aperture);
            Assert.AreEqual(ExampleItem.ShutterSpeed, result.ShutterSpeed);
            Assert.AreEqual(ExampleItem.IsoSpeed, result.IsoSpeed);
            Assert.AreEqual(ExampleItem.Software, result.Software);
            Assert.AreEqual(ExampleItem.MakeModel, result.MakeModel);
            Assert.AreEqual(ExampleItem.FocalLength, result.FocalLength);
        }