private static string SerializePlaylist(IPlaylist playlist, Format fileFormat) { switch (fileFormat) { case Format.XSPF: var xspfSerializer = new XspfSerializer(); var xspfPl = new XspfPlaylist(playlist); return(xspfSerializer.Serialize(xspfPl)); case Format.WPL: var wplSerializer = new WplSerializer(); var wplPlaylist = new WplPlaylist(playlist); return(wplSerializer.Serialize(wplPlaylist)); case Format.M3U: var m3USerializer = new M3uSerializer(); var m3UPlaylist = new M3uPlaylist(playlist); return(m3USerializer.Serialize(m3UPlaylist)); case Format.ASX: var asxSerializer = new AsxSerializer(); var asxPlaylist = new AsxPlaylist(playlist); return(asxSerializer.Serialize(asxPlaylist)); case Format.PLS: var plsSerializer = new PlsSerializer(); var plsPlaylist = new PlsPlaylist(playlist); return(plsSerializer.Serialize(plsPlaylist)); } return(String.Empty); }
public void Serialize_NullInput_ThrowsException() { var serializer = new WplSerializer(); Action act = () => serializer.Serialize(null); act.Should().Throw <ArgumentNullException>(); }
public void Serialize_GivenAuthor_SerializeTheAuthor() { var pattern = PrepareXmlForPatternMatching(@" <head> <author>Foo</author> </head> "); var playlist = new WplPlaylist { Author = "Foo" }; var serializer = new WplSerializer(); var actual = serializer.Serialize(playlist); actual.Should().MatchRegex(pattern); }
public void Serialize_GivenATag_SerializeTheTag() { var pattern = PrepareXmlForPatternMatching(@" <head> <meta name=""Foo"" content=""Bar"" /> </head> "); var serializer = new WplSerializer(); var playlist = new WplPlaylist(); playlist.Tags["Foo"] = "Bar"; var actual = serializer.Serialize(playlist); actual.Should().MatchRegex(pattern); }
public void Serialize_EmptyPlaylist_ReturnsEmptyPlaylistStr() { var pattern = PrepareXmlForPatternMatching(@" <\?wpl .*\?> <smil .*> <head /> <body> <seq /> </body> </smil> "); var serializer = new WplSerializer(); var output = serializer.Serialize(new WplPlaylist()); output.Should().MatchRegex(pattern); }
public void Serialize_GivenAMedia_SerializeTheMedia() { var pattern = PrepareXmlForPatternMatching(@" <body> <seq> <media src=""Foo"" /> </seq> </body> "); var playlist = new WplPlaylist(); playlist.Add(new WplItem("Foo")); var serializer = new WplSerializer(); var actual = serializer.Serialize(playlist); actual.Should().MatchRegex(pattern); }
public void Serialize_GivenTitle_SerializeTheTitle() { var pattern = PrepareXmlForPatternMatching(@" <head> <title>Foo</title> </head> "); var playlist = new WplPlaylist { Title = "Foo" }; var serializer = new WplSerializer(); var actual = serializer.Serialize(playlist); actual.Should().MatchRegex(pattern); }
public WplSerializerTests() { serializer = new WplSerializer(); }