Пример #1
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);
 }
Пример #2
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);
                }
            }
        }