コード例 #1
0
        public void ReadPlaylist_NestedCustomData()
        {
            string           sourcePlaylist = Path.Combine(ReadOnlyData, "MDBB.blist");
            IPlaylistHandler handler        = new BlistPlaylistHandler();

            Assert.IsTrue(File.Exists(sourcePlaylist), $"File doesn't exist: '{sourcePlaylist}'");
            using Stream playlistStream = File.OpenRead(sourcePlaylist);
            IPlaylist playlist = handler.Deserialize(playlistStream);

            Assert.AreEqual(7, playlist.Count);
            if (playlist.CustomData != null)
            {
                if (playlist.CustomData.TryGetValue("NestedObject", out object?value))
                {
                    if (value is JObject jObj)
                    {
                        Assert.AreEqual(jObj["NestedTest"], "test");
                    }
                    else
                    {
                        Assert.Fail("value isn't a JObject");
                    }
                }
                else
                {
                    Assert.Fail("NestedObject not found in CustomData");
                }
            }
            else
            {
                Assert.Fail("CustomData is null.");
            }
            Assert.IsTrue(playlist.All(s => s.Hash != null && s.Hash.Length == 40));
        }
コード例 #2
0
        public void ReadPlaylist_WithImage()
        {
            string           sourcePlaylist = Path.Combine(ReadOnlyData, "MDBB.blist");
            IPlaylistHandler handler        = new BlistPlaylistHandler();

            Assert.IsTrue(File.Exists(sourcePlaylist), $"File doesn't exist: '{sourcePlaylist}'");
            using Stream playlistStream = File.OpenRead(sourcePlaylist);
            IPlaylist playlist = handler.Deserialize(playlistStream);

            Assert.AreEqual(7, playlist.Count);
            Assert.IsTrue(playlist.All(s => s.Hash != null && s.Hash.Length == 40));
        }