/// <summary> /// Create a wiki site, login if necessary. /// </summary> private async Task <WikiSite> CreateWikiSiteAsync(IWikiClient wikiClient, string url) { WikiSite site; if (url.Contains(".wikia.com")) { var uri = new Uri(url, UriKind.Absolute); var options = new WikiaSiteOptions(uri.GetLeftPart(UriPartial.Authority) + "/") { AccountAssertion = AccountAssertionBehavior.AssertAll, }; site = new WikiaSite(wikiClient, options) { Logger = OutputLoggerFactory.CreateLogger <WikiaSite>() }; } else { var options = new SiteOptions(url) { AccountAssertion = AccountAssertionBehavior.AssertAll, }; site = new WikiSite(wikiClient, options) { Logger = OutputLoggerFactory.CreateLogger <WikiSite>() }; } await site.Initialization; if (sitesNeedsLogin.Contains(url)) { await CredentialManager.LoginAsync(site); } return(site); }
protected WikiClient CreateWikiClient() { var client = new WikiClient { Timeout = TimeSpan.FromSeconds(20), RetryDelay = TimeSpan.FromSeconds(5), ClientUserAgent = "UnitTest/1.0 (.NET CLR)", Logger = OutputLoggerFactory.CreateLogger <WikiClient>(), }; return(client); }
protected WikiClient CreateWikiClient() { var client = new WikiClient { Timeout = TimeSpan.FromSeconds(20), RetryDelay = TimeSpan.FromSeconds(5), #if ENV_CI_BUILD ClientUserAgent = $"UnitTest/1.0 ({RuntimeInformation.FrameworkDescription}; ENV_CI_BUILD)", #else ClientUserAgent = $"UnitTest/1.0 ({RuntimeInformation.FrameworkDescription})", #endif Logger = OutputLoggerFactory.CreateLogger <WikiClient>(), }; return(client); }
/// <summary> /// Create a wiki site, login if necessary. /// </summary> private async Task <WikiSite> CreateWikiSiteAsync(IWikiClient wikiClient, string url) { WikiSite site; if (url.Contains(".wikia.com") || url.Contains(".wikia.org") || url.Contains(".fandom.com")) { var uri = new Uri(url, UriKind.Absolute); var rootUrl = new Uri(uri, ".").ToString(); var options = new WikiaSiteOptions(rootUrl) { AccountAssertion = AccountAssertionBehavior.AssertAll, }; site = new WikiaSite(wikiClient, options) { Logger = OutputLoggerFactory.CreateLogger <WikiaSite>() }; } else { var options = new SiteOptions(url) { AccountAssertion = AccountAssertionBehavior.AssertAll, }; site = new WikiSite(wikiClient, options) { Logger = OutputLoggerFactory.CreateLogger <WikiSite>() }; } await site.Initialization; if (sitesNeedsLogin.Contains(url)) { await CredentialManager.LoginAsync(site); } return(site); }