Exemplo n.º 1
0
        public void FileNoExtension()
        {
            string           playlistDir = Path.Combine(OutputPath, "NoExtension");
            IPlaylistHandler handler     = new LegacyPlaylistHandler();
            PlaylistManager  manager     = TestTools.GetPlaylistManager(playlistDir, handler);

            File.Copy(Path.Combine(ReadOnlyData, "NoExtension"), Path.Combine(playlistDir, "NoExtension"));
            string playlistFileName = "NoExtension";

            Assert.IsNull(manager.GetPlaylist(playlistFileName));

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 2
0
        public void DeserializationError()
        {
            string           playlistDir = Path.Combine(OutputPath, "NoExtension");
            IPlaylistHandler handler     = new LegacyPlaylistHandler();
            PlaylistManager  manager     = TestTools.GetPlaylistManager(playlistDir, handler);

            File.Copy(Path.Combine(ReadOnlyData, "InvalidJson.bPlist"), Path.Combine(playlistDir, "InvalidJson.bPlist"));
            string playlistFileName = "InvalidJson";

            Assert.ThrowsException <PlaylistSerializationException>(() => manager.GetPlaylist(playlistFileName));

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 3
0
        public void EmptyFilename()
        {
            string           playlistDir      = Path.Combine(OutputPath, "");
            IPlaylistHandler handler          = new LegacyPlaylistHandler();
            PlaylistManager  manager          = TestTools.GetPlaylistManager(playlistDir, handler);
            string           playlistFileName = "";

            IPlaylist?playlist = manager.GetPlaylist(playlistFileName);

            Assert.IsNull(playlist);

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 4
0
        public void NoMatchingHandler()
        {
            string           playlistDir      = Path.Combine(OutputPath, "NoMatchingHandler");
            IPlaylistHandler defaultHandler   = new MockPlaylistHandler();
            PlaylistManager  manager          = TestTools.GetPlaylistManager(playlistDir, defaultHandler);
            string           playlistFileName = "5LegacySongs";

            // Check case-insensitive extensions
            File.Copy(Path.Combine(ReadOnlyData, "5LegacySongs.bPlist"), Path.Combine(playlistDir, "5LegacySongs.bPlist"));

            Assert.IsNull(manager.GetPlaylist(playlistFileName));

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 5
0
        public void PassedUnsupportedHandler()
        {
            string           playlistDir      = Path.Combine(OutputPath, "PassedUnsupportedHandler");
            IPlaylistHandler defaultHandler   = new LegacyPlaylistHandler();
            IPlaylistHandler providedHandler  = new MockPlaylistHandler();
            PlaylistManager  manager          = TestTools.GetPlaylistManager(playlistDir, defaultHandler);
            string           playlistFileName = "5LegacySongs";

            File.Copy(Path.Combine(ReadOnlyData, "5LegacySongs.bPlist"), Path.Combine(playlistDir, "5LegacySongs.bPlist"));

            Assert.ThrowsException <ArgumentException>(() => manager.GetPlaylist(playlistFileName, false, providedHandler));

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 6
0
        public void NewHandler()
        {
            string           playlistDir     = Path.Combine(OutputPath, "NewHandler");
            IPlaylistHandler expectedHandler = new LegacyPlaylistHandler();

            PlaylistManager manager = TestTools.GetPlaylistManager(playlistDir, new MockPlaylistHandler());

            Assert.IsNull(manager.GetHandlerForExtension("bplist"));
            Assert.IsNull(manager.GetHandlerForExtension("json"));

            manager.RegisterHandlerForExtension("json", expectedHandler);

            Assert.AreEqual(typeof(MockPlaylistHandler), manager.DefaultHandler?.GetType());
            Assert.AreEqual(expectedHandler, manager.GetHandlerForExtension("json"));
            Assert.IsNull(manager.GetHandlerForExtension("bplist"));

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 7
0
        public void ExtensionHasCapital()
        {
            string           playlistDir      = Path.Combine(OutputPath, "ExtensionHasCapital");
            IPlaylistHandler handler          = new LegacyPlaylistHandler();
            PlaylistManager  manager          = TestTools.GetPlaylistManager(playlistDir, handler);
            string           playlistFileName = "5LegacySongs";

            File.Copy(Path.Combine(ReadOnlyData, "5LegacySongs.bPlist"), Path.Combine(playlistDir, "5LegacySongs.bPlist"));
            IPlaylist?playlist = null;

            playlist = manager.GetPlaylist(playlistFileName);
            Assert.IsNotNull(playlist);
            if (playlist == null)
            {
                return;
            }
            Assert.AreEqual(5, playlist.Count);

            TestTools.Cleanup(playlistDir);
        }
Exemplo n.º 8
0
        public void ExistingHandlerType()
        {
            string           playlistDir     = Path.Combine(OutputPath, "ExistingHandlerType");
            IPlaylistHandler existingHandler = new LegacyPlaylistHandler();
            IPlaylistHandler expectedHandler = new LegacyPlaylistHandler();
            string           extension       = "json";

            PlaylistManager manager = TestTools.GetPlaylistManager(playlistDir, existingHandler);

            manager.RegisterHandlerForExtension(extension, expectedHandler);
            IPlaylistHandler?actualHandler = manager.GetHandlerForExtension(extension);
            IPlaylistHandler?bplistHandler = manager.GetHandlerForExtension("bplist");

            Assert.IsTrue(Directory.Exists(playlistDir));
            Assert.AreEqual(expectedHandler, actualHandler);
            Assert.IsNotNull(bplistHandler);
            Assert.AreNotEqual(actualHandler, bplistHandler);

            TestTools.Cleanup(playlistDir);
        }