예제 #1
0
        public void Deserialize_MediaWithInvalidDuration_ThrowsException()
        {
            var deserializer = new M3uDeserializer();

            Action act = () => deserializer.Deserialize("#EXTM3U\n#EXTINF:42.foo\nfoo.bar\n");

            act.Should().Throw <MediaFormatException>();
        }
예제 #2
0
        public void Deserialize_MediaWithValidDuration_DurationIsCorrectlyExtracted()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n#EXTINF:42.42\nfoo.bar\n");

            output.Items.First().Duration.Should().Be(42.42m);
        }
예제 #3
0
        public void Deserialize_DifferentTypesOfNewLines_ParseAsExpected(string newLine)
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize($"#EXTM3U{newLine}#EXTINF:42.42{newLine}foo.bar{newLine}");

            output.Items.Should().NotBeEmpty();
        }
예제 #4
0
        public void Deserialize_MediaWithNoPath_ThrowsException()
        {
            var deserializer = new M3uDeserializer();

            Action act = () => deserializer.Deserialize("#EXTM3U\n#Foo:42\n");

            act.Should().Throw <FormatException>();
        }
예제 #5
0
        public void Deserialize_GivenEmptyPlaylist_ReturnsEmptyPlaylist()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U");

            output.Items.Should().BeEmpty();
        }
예제 #6
0
        public void Deserialize_TrashMediaTag_ThrowsException()
        {
            var deserializer = new M3uDeserializer();

            Action act = () => deserializer.Deserialize("#EXTM3U\n#Foo:42\nfoo.bar\n");

            act.Should().Throw <MediaFormatException>();
        }
예제 #7
0
        public void Deserialize_MeidaTitleContainsComma_TitleExtracteWithComma()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n#EXTINF:42, Foo, Bar\nfoo.bar\n");

            output.Items.First().Title.Should().Be("Foo, Bar");
        }
예제 #8
0
        public void Deserialize_InvalidHeader_ThrowsException()
        {
            var deserializer = new M3uDeserializer();

            Action act = () => deserializer.Deserialize("#M3uFoo\n");

            act.Should().Throw <FormatException>();
        }
예제 #9
0
        public void Deserialize_MediaAndUnnecessaryNewlines_ExtraNewlinesAreIgnored()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n\n\n\n\n\n\n#EXTINF:42\nfoo.bar\n");

            output.Items.Should().NotBeEmpty();
        }
예제 #10
0
        public void Deserialize_MediaWithTwoItems_TwoItemsAreExtracted()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n#EXTINF:42\nfoo.bar\n#EXTINF:42\nfoo.bar\n");

            output.Items.Should().HaveCount(2);
        }
예제 #11
0
        public void Deserialize_MediaWithPath_PathIsCorrectlyExtracted()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n#EXTINF:42\nfoo.bar\n");

            output.Items.First().Path.Should().Be("foo.bar");
        }
예제 #12
0
        public void Deserialize_NullInput_ThrowsException()
        {
            var deserializer = new M3uDeserializer();

            Action act = () => deserializer.Deserialize(null);

            act.Should().Throw <ArgumentNullException>();
        }
예제 #13
0
        public void Deserialize_MediaWithTitle_TitleIsCorrectlyExtracted()
        {
            var deserializer = new M3uDeserializer();

            var output = deserializer.Deserialize("#EXTM3U\n#EXTINF:42, Foo\nfoo.bar\n");

            output.Items.First().Title.Should().Be("Foo");
        }
예제 #14
0
 public void Deserialize_NullInput_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() => deserializer.Deserialize(null));
 }