Esempio n. 1
0
        public void NotCorrectPatternAddTags()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("myartist - mysong").
                    Tag(FrameType.Artist, "Not my artist").
                    Build()).
                Build();
            var fileProcesor = new Mp3FileProcessor(fileHandler);

            Assert.AreEqual(false, fileProcesor.RetagFile("<ar><ti>"));
        }
Esempio n. 2
0
        public void NotCorrectPatternRenameFile()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("my name").
                    Tag(FrameType.Artist, "myartist").
                    Tag(FrameType.Title, "mysong").
                    Build()).
                Build();

            var fileProcesor = new Mp3FileProcessor(fileHandler);

            Assert.AreEqual(false, fileProcesor.RenameFile("<a> - <ti>"));
        }
Esempio n. 3
0
        public void NoDifferenceTest()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("my artist - my song").
                    Tag(FrameType.Artist, "my artist").
                    Tag(FrameType.Title, "my song").
                    Build()).
                Build();

            var fileProcesor = new Mp3FileProcessor(fileHandler);

            var result = fileProcesor.Difference("<ar> - <ti>");

            Assert.AreEqual(null, result);
        }
Esempio n. 4
0
 public Dictionary<string, Dictionary<FrameType, TagDifference>> GetDifferences(string path, string pattern)
 {
     var files = _folderHandler.GetAllMp3s(path);
     if (files.Count == 0)
         return null;
     var mp3Processor = new Mp3FileProcessor(_lateFileHandler);
     var differences = new Dictionary<string, Dictionary<FrameType, TagDifference>>();
     foreach (var file in files)
     {
         _lateFileHandler.FilePath = file;
         var diff = mp3Processor.Difference(pattern);
         if(diff != null)
             differences.Add(file,diff);
     }
     return differences;
 }
Esempio n. 5
0
        public bool PrepareSynch(string path, string pattern)
        {
            if (!_synchInProgres)
            {
                var mp3Processor = new Mp3FileProcessor(_lateFileHandler);

                var files = _folderHandler.GetAllMp3s(path);
                if (files.Count == 0)
                    return false;
                _synchInProgres = true;

                foreach (var file in files)
                {
                    _lateFileHandler.FilePath = file;
                    mp3Processor.Synchronize(pattern);
                }
                return true;
            }
            return false;
        }
Esempio n. 6
0
        public void BadFileSynch()
        {
            var expect = new Dictionary<FrameType, string>()
            {
                {FrameType.Artist, "my artist"},
                {FrameType.Title, "my song"}
            };

            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("my artist - my song").
                    Build()).
                Build();

            fileHandler.Tags.Add(FrameType.Artist, "artist");
            var fileProcesor = new Mp3FileProcessor(fileHandler);

            Assert.AreEqual(true, fileProcesor.Synchronize("<ar> - <ti>"));

            CollectionAssert.AreEquivalent(expect, fileHandler.Tags);
        }
Esempio n. 7
0
 private static void LaunchRetagMode(string path, string pattern)
 {
     var retager = new Mp3FileProcessor(path);
     retager.RetagFile(pattern);
 }
Esempio n. 8
0
        public void OneItemDifferenceTest()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("not my artist - my song").
                    Tag(FrameType.Artist, "my artist").
                    Tag(FrameType.Title, "my song").
                    Build()).
                Build();

            var fileProcesor = new Mp3FileProcessor(fileHandler);

            var fileExpect = "my artist";
            var pathExpect = "not my artist";

            var result = fileProcesor.Difference("<ar> - <ti>");

            Assert.AreEqual(1,result.Count);
            Assert.AreEqual(fileExpect,result[FrameType.Artist].FileValue);
            Assert.AreEqual(pathExpect,result[FrameType.Artist].PathValue);
        }
Esempio n. 9
0
        public void SimpleAddTagsToNotEmptyFile()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("myartist - mysong").
                    Tag(FrameType.Artist, "Not my artist").
                    Build()).
                Build();
            var fileProcesor = new Mp3FileProcessor(fileHandler);

            var expect = new Dictionary<FrameType, string>
            {
                {FrameType.Artist, "myartist"},
                {FrameType.Title, "mysong"}
            };

            Assert.AreEqual(true, fileProcesor.RetagFile("<ar> - <ti>"));

            CollectionAssert.AreEquivalent(expect, fileHandler.Tags);
        }
Esempio n. 10
0
        public void RenameFile()
        {
            var fileHandler = new FileSystemBuilder().
                ActualFile(new FileBuilder().
                    FilePath("my name").
                    Tag(FrameType.Artist, "myartist").
                    Tag(FrameType.Title, "mysong").
                    Build()).
                Build();

            var fileProcesor = new Mp3FileProcessor(fileHandler);

            Assert.AreEqual(true, fileProcesor.RenameFile("<ar> - <ti>"));

            Assert.AreEqual("myartist - mysong", fileHandler.FileName);
        }