public void GetImageProperties_NoFile_EmptyResult()
        {
            var    runExifTool     = new RunExifTool("a", true);
            string imageProperties = runExifTool.GetImageProperties();

            Assert.IsTrue(string.IsNullOrEmpty(imageProperties));
        }
Exemple #2
0
        public void SuggestTitle_FromFileName_NoLogicInName_SuggestsEmpty()
        {
            const string noDateNoTitle = "NoDateHintNoTitle2.jpg";

            File.Copy(TestingImagesNames.NoDateHint, noDateNoTitle);
            var  exifTool = new RunExifTool(noDateNoTitle, false);
            bool success  = exifTool.SetTitle(string.Empty);

            Assert.IsTrue(success);

            string imageFileName = "__7_0134.jpg";

            File.Copy(noDateNoTitle, imageFileName);
            var sut = new ImageFilePropertiesChanger(imageFileName, true);

            Assert.AreEqual(null, sut.GetValueForTitle());

            imageFileName = "10A_0216.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual(null, sut.GetValueForTitle());

            imageFileName = "22A_0386.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual(null, sut.GetValueForTitle());

            imageFileName = "F1000019.JPG";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual(null, sut.GetValueForTitle());
        }
        public void GetImageProperties_FileExists_Success()
        {
            string imageFileName   = TestingImagesNames.LeahOnShip1957;
            var    runExifTool     = new RunExifTool(imageFileName, false);
            string imageProperties = runExifTool.GetImageProperties();

            Assert.IsNotNull(imageProperties);
        }
        public void SetImageProperties_SetTitle_TitleMatches()
        {
            string testImage = "_SetTitle_.jpg";

            File.Copy(TestingImagesNames.LeahOnShip1957, testImage);
            var          runExifTool     = new RunExifTool(testImage, false);
            const string testHadSetTitle = "Test Had Set ExTitle";

            runExifTool.SetTitle(testHadSetTitle);
            var imageProperties = new ImageProperties(testImage);

            Assert.AreEqual(testHadSetTitle, imageProperties.ExTitle);
        }
        public void SetImageProperties_SetTitleAndDate_ValuesMatch()
        {
            string imageFileName = "SetTitleAndDate.jpg";

            File.Copy(TestingImagesNames.LeahOnShip1957, imageFileName);

            var          runExifTool       = new RunExifTool(imageFileName, false);
            const string testHadSetTitle   = "Test Had Set ExTitle";
            DateTime     expectedDateTaken = new DateTime(1980, 12, 12);

            runExifTool.SetDateAndTitle(testHadSetTitle, expectedDateTaken);
            var imageProperties = new ImageProperties(imageFileName);

            Assert.AreEqual(testHadSetTitle, imageProperties.ExTitle);
            Assert.AreEqual(expectedDateTaken, imageProperties.DateTaken);
        }
        public void SetImageProperties_FullFileNamePathContainsSpacesAndHebrew_SetTitleAndDate_ValuesMatch()
        {
            const string subFolder    = "20080328 מרפסת ותפלץ\\20080328";
            string       copyToFolder = Path.Combine(Environment.CurrentDirectory, subFolder);

            if (!Directory.Exists(copyToFolder))
            {
                Directory.CreateDirectory(copyToFolder);
            }

            string imageFileName = Path.Combine(copyToFolder, TestingImagesNames.LeahOnShip1957);

            File.Copy(TestingImagesNames.LeahOnShip1957, imageFileName);

            var          runExifTool       = new RunExifTool(imageFileName, false);
            const string testHadSetTitle   = "דפנה לולו";
            DateTime     expectedDateTaken = new DateTime(1980, 12, 12);

            runExifTool.SetDateAndTitle(testHadSetTitle, expectedDateTaken);
            var imageProperties = new ImageProperties(imageFileName);

            Assert.AreEqual(testHadSetTitle, imageProperties.ExTitle);
            Assert.AreEqual(expectedDateTaken, imageProperties.DateTaken);
        }
Exemple #7
0
        public void SuggestTitle_FromFileName_Success()
        {
            string testImage = TestingImagesNames.NoDateHint;
            var    sut       = new ImageFilePropertiesChanger(testImage, false);

            Assert.AreEqual("this is the title", sut.GetValueForTitle());

            const string noDateNoTitle = "NoDateHintNoTitle.jpg";

            File.Copy(testImage, noDateNoTitle);
            var  exifTool = new RunExifTool(noDateNoTitle, false);
            bool success  = exifTool.SetTitle(string.Empty);

            Assert.IsTrue(success);
            sut = new ImageFilePropertiesChanger(noDateNoTitle, true);
            Assert.AreEqual("No Date Hint No Title", sut.GetValueForTitle());
            //__7_0134.jpg, 10A_0216.jpg, 22A_0386.jpg, F1000019.JPG
            string imageFileName = "Leah_Small_Child.jpg";

            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Leah Small Child", sut.GetValueForTitle());

            imageFileName = "Leah_OnShip_2047.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Leah On Ship", sut.GetValueForTitle());

            imageFileName = "LeahOnShip_1957_blah.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Leah On Ship 1957 blah", sut.GetValueForTitle());

            imageFileName = "Zelma_Rosenthal_(KoonZ).jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Zelma Rosenthal (Koon Z)", sut.GetValueForTitle());

            imageFileName = "בית_גרטה_פריץ_בנימינה_1871.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("בית גרטה פריץ בנימינה", sut.GetValueForTitle());

            imageFileName = "2007_0926Keswick0020.JPG";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Keswick", sut.GetValueForTitle());

            imageFileName = "2007_0921EdinburghBotanicGarden38.JPG";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Edinburgh Botanic Garden", sut.GetValueForTitle());

            imageFileName = "20070921EdinburghBotanicGarden_36A_0582.jpg";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Edinburgh Botanic Garden", sut.GetValueForTitle());

            imageFileName = "20070920EdinburghCastle_F1030008.JPG";
            File.Copy(noDateNoTitle, imageFileName);
            sut = new ImageFilePropertiesChanger(imageFileName, true);
            Assert.AreEqual("Edinburgh Castle", sut.GetValueForTitle());
        }