Exemple #1
0
        private static void TestFine()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumExplorerProcessor\TestFine\");
            TestTags.CreateDemoTags(path, 6, n => n.Album = "Album");

            AlbumExplorerProcessor processor = new AlbumExplorerProcessor();

            bool succeded = false;
            bool failed = false;

            processor.FineCallback += delegate(AlbumExplorer.AlbumResult album)
            {
                UnitTest.Test(album.Album.Result == AlbumExplorer.ParseResult.Fine);
                UnitTest.Test(album.Album[FrameMeaning.Artist] == "Artist");
                UnitTest.Test(album.Album[FrameMeaning.Album] == "Album");
                UnitTest.Test(album.Album[FrameMeaning.ReleaseYear] == "1993");

                succeded = true;
            };
            processor.BadCallback += delegate(AlbumExplorer.AlbumResult album)
            {
                failed = true;
            };

            processor.Process(new DirectoryInfo(path));

            UnitTest.Test(succeded);
            UnitTest.Test(!failed);

            VirtualDrive.DeleteDirectory(path, true);
        }
Exemple #2
0
        private static void TestFine_NoReleaseYearRequired()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumExplorerProcessor\TestFine_NoReleaseYearRequired\");
            TestTags.CreateDemoTags(path, 6, n => n.ReleaseYear = "");

            AlbumExplorerProcessor processor = new AlbumExplorerProcessor();
            processor.Explorer.ReleaseYearRequired = false;

            TestSuccess(path, processor);
        }
Exemple #3
0
        private static void TestFailingPattern()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumTagToFilenameProcessor\TestFailingPattern\");

            TestTags.CreateDemoTags(path, 6, n => n.Artist = null);

            string[] filesBefore = VirtualDrive.GetFiles(path, "*.mp3");

            AlbumTagToFilenameProcessor processor = new AlbumTagToFilenameProcessor(
                "Artist - Album - TrackNumber - Title");

            processor.Process(new DirectoryInfo(path));

            string[] filesAfter = VirtualDrive.GetFiles(path, "*.mp3");

            UnitTest.Test(filesBefore.SequenceEqual(filesAfter));

            VirtualDrive.DeleteDirectory(path, true);
        }
Exemple #4
0
        private static void TestBad()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumExplorerProcessor\TestBadArtistMissing\");

            TestTags.CreateDemoTags(path, 6, n => n.Artist = "");
            TestFailure(path, AlbumExplorer.ParseResult.ArtistNameFailed);

            TestTags.CreateDemoTags(path, 6, n => n.Album = "");
            TestFailure(path, AlbumExplorer.ParseResult.AlbumNameFailed);

            TestTags.CreateDemoTags(path, 6, n => n.Title = "");
            TestFailure(path, AlbumExplorer.ParseResult.TrackNameMissing);

            TestTags.CreateDemoTags(path, 6, n => n.TrackNumber = "");
            TestFailure(path, AlbumExplorer.ParseResult.TrackIndexFailed);

            TestTags.CreateDemoTags(path, 6, n => n.Title = "Track");
            TestFailure(path, AlbumExplorer.ParseResult.TrackNameDummy);

            TestTags.CreateDemoTags(path, 6, n => n.ReleaseYear = "");
            TestFailure(path, AlbumExplorer.ParseResult.YearFailed);
        }
Exemple #5
0
        private static void TestFullPattern()
        {
            string path = VirtualDrive.VirtualFileName(@"TestAlbumTagToFilenameProcessor\TestFullPattern\");

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

            AlbumTagToFilenameProcessor processor = new AlbumTagToFilenameProcessor(
                "Artist - Album - TrackNumber - Title");

            processor.Process(new DirectoryInfo(path));

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

            UnitTest.Test(files.Length == 6);
            for (int i = 0; i < files.Length; i++)
            {
                string expected = Path.Combine(path, "Artist - Album - " + (i + 1) + " - Song No. " + (i + 1) + ".mp3");
                UnitTest.Test(files[i] == expected);
            }

            VirtualDrive.DeleteDirectory(path, true);
        }
        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);
        }
        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);
        }