Skip to content

[Development] Unit tests

Chen edited this page Nov 9, 2017 · 2 revisions

Setting up test cases

Before you can run most of the test cases, please create a new file named credentials.cs and place it under \UnitTestProject1\_private folder. The content should be like this

using System;
using WikiClientLibrary;
using WikiClientLibrary.Sites;

namespace UnitTestProject1
{
    partial class CredentialManager
    {
        static partial void LoginCore(WikiSite site)
        {
            var url = site.ApiEndpoint;
          // We'll make changes to test2.wikipedia.org
            if (url.Contains("wikipedia.org"))
                Login(site, "Anne", "password" );
          // We'll make changes to MediaWiki 119 test Wiki
            else if (url.Contains("wikia.com"))
                Login(site, "Bob", "password");
          // Add other login routines if you need to.
            else if (url.contains("domain.com"))
                Login(site, "Calla", "password");
            else
                throw new NotSupportedException();
        }

        static partial void Initialize()
        {
          // A place to perform page moving and deleting
          // You should have the bot or sysop right there
          DirtyTestsEntryPointUrl = "http://testwiki.domain.com/api.php";
          // A private wiki API entrypoint, where anonymous
          // users have no read permission.
          PrivateWikiTestsEntryPointUrl = null;
        }
    }
}

You need to put valid user names and passwords into this file. As for the special API entry point URLs, they are optional, but certain tests will not work if you neglect or set them to null. As is configured in .gitignore, this file WILL NOT be included in the repository.

Clone this wiki locally