Esempio n. 1
0
        public virtual void OnBad(AlbumExplorer.AlbumResult album)
        {
            NumberOfBads++;

            if (!Object.ReferenceEquals(OnBadProcessor, null))
                OnBadProcessor.Process(album);
            if (!Object.ReferenceEquals(BadCallback, null))
                BadCallback(album);

            if (Verbose)
            {
                Logger.WriteLine(Tokens.Info, "BAD:  " + album.Directory + " (" + album.Album.Result + ")");
            }
        }
Esempio n. 2
0
        public virtual void OnFine(AlbumExplorer.AlbumResult album)
        {
            NumberOfFines++;

            if (!Object.ReferenceEquals(OnFineProcessor, null))
                OnFineProcessor.Process(album);
            if (!Object.ReferenceEquals(FineCallback, null))
                FineCallback(album);

            if (Verbose)
            {
                Logger.WriteLine(Tokens.Info, "FINE: " + album.Directory.FullName);
            }
        }
Esempio n. 3
0
        public virtual void Process(Object obj)
        {
            AlbumExplorer.AlbumResult result = Explorer.ExploreDirectory(obj as DirectoryInfo);

            if (result.Album.Result != AlbumExplorer.ParseResult.NoMp3s)
            {
                if (result.Album.Result == AlbumExplorer.ParseResult.Fine)
                {
                    OnFine(result);
                }
                else
                {
                    OnBad(result);
                }
            }
        }
        private static void TestFullPattern()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumTagToDirectoryProcessor\TestFullPattern\");

            TestTags.CreateDemoTags(path, 6, n => n.ReleaseYear = "1993");

            AlbumTagToDirectoryProcessor processor = new AlbumTagToDirectoryProcessor(
                "Artist - Album{ (ReleaseYear)}");

            AlbumExplorer.AlbumResult obj =
                new AlbumExplorer.AlbumResult(new DirectoryInfo(path));
            obj.Album[FrameMeaning.Artist]      = "Artist";
            obj.Album[FrameMeaning.Album]       = "Album";
            obj.Album[FrameMeaning.ReleaseYear] = "1993";

            processor.Process(obj);

            string expectedPath = VirtualDrive.VirtualFileName(
                @"TestAlbumTagToDirectoryProcessor\Artist - Album (1993)\");

            VirtualDrive.ExistsDirectory(expectedPath);
            VirtualDrive.DeleteDirectory(expectedPath, true);
        }
Esempio n. 5
0
        private static void TestCopy()
        {
            string pathSrc     = VirtualDrive.VirtualFileName(@"TestAlbumToLibraryProcessor\TestCopy\Src\");
            string pathLibrary = VirtualDrive.VirtualFileName(@"TestAlbumToLibraryProcessor\TestCopy\Lib\");

            VirtualDrive.Store(Path.Combine(pathLibrary, "test.mp3"), new byte[] {});
            TestTags.CreateDemoTags(pathSrc, 3, n => n.ReleaseYear = "1993");

            AlbumToLibraryProcessor processor = new AlbumToLibraryProcessor(
                pathLibrary, FileOperationProcessor.FileOperation.Copy, FileOperationProcessor.ConflictSolving.Skip);

            AlbumExplorer.AlbumResult obj =
                new AlbumExplorer.AlbumResult(new DirectoryInfo(pathSrc));
            obj.Album[FrameMeaning.Artist]      = "Artist";
            obj.Album[FrameMeaning.Album]       = "Album";
            obj.Album[FrameMeaning.ReleaseYear] = "1993";

            processor.Process(obj);

            VirtualDrive.ExistsDirectory(pathSrc);

            string expectedDst = Path.Combine(pathLibrary, "Artist - Album (1993)");

            VirtualDrive.ExistsDirectory(expectedDst);

            string[] files = VirtualDrive.GetFiles(expectedDst, "*.mp3");

            UnitTest.Test(files.Length == 3);
            for (int i = 0; i < files.Length; i++)
            {
                string expected = Path.Combine(expectedDst, "Test" + i + ".mp3");
                UnitTest.Test(files[i] == expected);
            }

            VirtualDrive.DeleteDirectory(pathSrc, true);
            VirtualDrive.DeleteDirectory(pathLibrary, true);
        }