Inheritance: IMp3File
Ejemplo n.º 1
0
        public void Test_NewFileName()
        {
            var mp3 = new TestMp3File("C:/test/mp3s/1. asd - qwe.mp3") {Artist = "art", TrackId = "1", Title = "ttl"};
            var renamer = new Mp3FileNameChanger(mp3, "{id}. {artist} - {title}", new TestRollbackSaver(new [] {""}));

            Assert.AreEqual("1. art - ttl", renamer.GetNewFileName());
        }
Ejemplo n.º 2
0
 public void TestInit()
 {
     _mp3File = new TestMp3File("/test");
     _fileDiff = new FileDifferences(_mp3File);
     _d1 = new Diff { FileNameValue = "1", TagValue = "2" };
     _d2 = new Diff { FileNameValue = "art1", TagValue = "art2" };
     _fileDiff.Add(TagType.Id, _d1);
     _fileDiff.Add(TagType.Artist, _d2);
 }
Ejemplo n.º 3
0
        public void Test_ManualFileNameReplacements()
        {
            var mp3 = new TestMp3File("C:/test/mp3s/1. asd - qwe.mp3") { Artist = "art", TrackId = "1", Title = "ttl" };
            var renamer = new Mp3FileNameChanger(mp3, "{id}. {artist} - {title}", new TestRollbackSaver(new[] { "" }));
            renamer.AddTagReplacement(TagType.Id, mp3.TrackId);
            renamer.AddTagReplacement(TagType.Artist, mp3.Artist);
            renamer.AddTagReplacement(TagType.Title, mp3.Title);

            Assert.AreEqual("1. art - ttl", renamer.GetNewFileName());
        }
Ejemplo n.º 4
0
        public void Test_Changer()
        {
            var file = new TestMp3File("[1999] 1. art1 - ttl1.mp3") { TrackId = "5", Artist = "art5", Title = "ttl5", Year = "1995"};
            const string mask = "[{year}] {id}. {artist} - {title}";
            var changer = new Mp3TagChanger(file, mask, new TestRollbackSaver(new List<string>()));
            changer.ChangeTags();

            Assert.AreEqual(file.Artist, "art1");
            Assert.AreEqual(file.TrackId, "1");
            Assert.AreEqual(file.Year, "1999");
            Assert.AreEqual(file.Title, "ttl1");
        }
Ejemplo n.º 5
0
        public void Test_AnalyserWithNotEnoughData()
        {
            var firstItem = new TestMp3File("1. name1 - title1.mp3") { TrackId = "1", Title = "title1", Artist = "name1" };
            var secondItem = new TestMp3File("2.  - title2.mp3") { TrackId = "1", Title = "title2", Artist = "name1" };
            var thirdItem = new TestMp3File("3. .mp3") { TrackId = "1", Title = "title3", Artist = "name3" };

            var files = new TestMp3File[]
            {
                firstItem,
                secondItem,
                thirdItem,
            };

            var analyser = new Mp3FileAnalyser(files, "{id}. {artist} - {title}");
            var diffs = analyser.GetDifferences().ToList();

            var expectedDiff1 = new FileDifferences(secondItem);
            expectedDiff1.Add(TagType.Id, new Diff { FileNameValue = "2", TagValue = "1" });
            expectedDiff1.Add(TagType.Artist, new Diff { FileNameValue = "", TagValue = "name1" });

            var expectedDiff2 = new FileDifferences(thirdItem);
            expectedDiff2.Add(TagType.Id, new Diff { FileNameValue = "3", TagValue = "1" });
            expectedDiff2.Add(TagType.Title, new Diff { FileNameValue = "", TagValue = "title3" });
            expectedDiff2.Add(TagType.Artist, new Diff { FileNameValue = "", TagValue = "name3" });

            var expectedDiffs = new List<FileDifferences>()
            {
                expectedDiff1,
                expectedDiff2,
            };

            Assert.AreEqual(expectedDiffs.Count, diffs.Count);

            for (var i = 0; i < diffs.Count; i++)
            {
                Assert.AreEqual(expectedDiffs[i].Mp3File, diffs[i].Mp3File);

                Assert.AreEqual(expectedDiffs[i].Diffs.Count, diffs[i].Diffs.Count);

                foreach (var diff in expectedDiffs[i].Diffs)
                {
                    Assert.AreEqual(expectedDiffs[i].Diffs[diff.Key].FileNameValue, diffs[i].Diffs[diff.Key].FileNameValue);
                    Assert.AreEqual(expectedDiffs[i].Diffs[diff.Key].TagValue, diffs[i].Diffs[diff.Key].TagValue);
                }
            }
        }
Ejemplo n.º 6
0
        public void Test_GetDataFromUser()
        {
            var communicator = new TestCommunicator(userInput: new[]{
                "3",
                "3", //it's entering a value
            });

            var item = new TestMp3File("1. name3 - title3.mp3") { TrackId = "3", Title = "title3", Artist = "name3" };

            var files = new[] {item};

            var syncer = new Mp3Syncing(files, "{id}. {artist} - {title}", communicator, new TestRollbackSaver(new[] { "" }));
            syncer.SyncFiles();

            Assert.AreEqual(item.TrackId, "3");
            Assert.AreEqual(item.Artist, "name3");
            Assert.AreEqual(item.Title, "title3");
        }
Ejemplo n.º 7
0
        public void Test_GetDataFromFileName()
        {
            var communicator = new TestCommunicator(userInput: new[]{
                "1",
                "1",
            });

            var item = new TestMp3File("2. name2 - title2.mp3") { TrackId = "1", Title = "title2", Artist = "name1" };

            var files = new[] {item};

            var syncer = new Mp3Syncing(files, "{id}. {artist} - {title}", communicator, new TestRollbackSaver(new[] { "" }));
            syncer.SyncFiles();

            Assert.AreEqual(item.TrackId, "2");
            Assert.AreEqual(item.Artist, "name2");
            Assert.AreEqual(item.Title, "title2");
        }