Exemplo n.º 1
0
        public async Task InterwikiLinkTests()
        {
            // We will not login onto any site…
            var originSite = await Family.GetSiteAsync("test2");

            // With originating WikiSite
            var link = await WikiLink.ParseAsync(originSite, Family, "WikiPedia:SANDBOX");

            AssertWikiLink(link, null, "Wikipedia", "SANDBOX");
            link = await WikiLink.ParseAsync(originSite, Family, "FR___:_ __Wp__ _:  SANDBOX");

            AssertWikiLink(link, "fr", "Wikipédia", "SANDBOX");
            link = await WikiLink.ParseAsync(originSite, Family, "EN:fr:   LZH:Project:SANDBOX");

            AssertWikiLink(link, "lzh", "維基大典", "SANDBOX");
            // We don't have de in WikiFamily, but WP has de in its inter-wiki table.
            // Should works as if we haven't specified Family.
            link = await WikiLink.ParseAsync(originSite, Family, "de:Project:SANDBOX");

            AssertWikiLink(link, "de", null, "Project:SANDBOX");
            // Without originating WikiSite
            await Assert.ThrowsAsync <ArgumentException>(() => WikiLink.ParseAsync(Family, "WikiPedia:SANDBOX"));

            link = await WikiLink.ParseAsync(Family, "FR___:_ __Wp__ _:  SANDBOX");

            AssertWikiLink(link, "fr", "Wikipédia", "SANDBOX");
            link = await WikiLink.ParseAsync(Family, "EN:fr:   LZH:Project:SANDBOX");

            AssertWikiLink(link, "lzh", "維基大典", "SANDBOX");
            await Assert.ThrowsAsync <ArgumentException>(() => WikiLink.ParseAsync(Family, "unk:WikiPedia:SANDBOX"));
        }
        public async Task InterwikiLinkTests()
        {
            // We will not login onto any site…
            var homeSite = await Family.GetSiteAsync("test2");

            var link = await WikiLink.ParseAsync(homeSite, Family, "WikiPedia:SANDBOX");

            AssertWikiLink(link, null, "Wikipedia", "SANDBOX");
            link = await WikiLink.ParseAsync(homeSite, Family, "FR___:_ __Wp__ _:  SANDBOX");

            AssertWikiLink(link, "fr", "Wikipédia", "SANDBOX");
            link = await WikiLink.ParseAsync(homeSite, Family, "EN:fr:   LZH:Project:SANDBOX");

            AssertWikiLink(link, "lzh", "維基大典", "SANDBOX");
        }