예제 #1
0
        public async Task ShouldExportOpmlFeedsIntoXml(string category, string protocol, string domain, string path)
        {
            Opml opml = null;

            _serializationService
            .When(x => x.Serialize(Arg.Any <Opml>(), Arg.Any <Stream>()))
            .Do(callback => opml = callback.Arg <Opml>());

            var url      = $"{protocol}{domain}{path}";
            var channels = new List <Channel> {
                new Channel {
                    Uri = url
                }
            };
            var categories = new List <Category> {
                new Category {
                    Title = category, Channels = channels
                }
            };

            _categoryManager.GetAll().Returns(categories);

            var success = await _opmlService.ExportOpml(new MemoryStream());

            success.Should().BeTrue();

            opml.Head.Should().NotBeNull();
            opml.Body.Count.Should().Be(1);
            opml.Body[0].Title.Should().Be(category);
            opml.Body[0].ChildOutlines.Count.Should().Be(1);
            opml.Body[0].ChildOutlines[0].Title.Should().Be(domain);
            opml.Body[0].ChildOutlines[0].HtmlUrl.Should().Be(protocol + domain);
            opml.Body[0].ChildOutlines[0].XmlUrl.Should().Be(url);
        }