예제 #1
0
    public void CreateWikiTest()
    {
        const string AdminId = "AdminId";

        var options   = new WikiOptions();
        var dataStore = new InMemoryDataStore();

        var welcome = GetDefaultWelcomeAsync(options, dataStore, AdminId).GetAwaiter().GetResult();

        Assert.AreEqual(ExpectedWelcome, welcome.Html, ignoreCase: false);

        var main    = GetDefaultMainAsync(options, dataStore, AdminId).GetAwaiter().GetResult();
        var missing = main.WikiLinks.FirstOrDefault(x => x.Missing);

        Assert.IsNotNull(missing);

        var category = Category.GetCategory(options, dataStore, "System pages");

        Assert.IsNotNull(category);
        SetDefaultCategoryAsync(options, dataStore, category !, AdminId).GetAwaiter().GetResult();
        missing = category.WikiLinks.FirstOrDefault(x => x.Missing);
        Assert.IsNotNull(missing);

        var about = GetDefaultAboutAsync(options, dataStore, AdminId).GetAwaiter().GetResult();

        main = dataStore.GetItem <Article>(main.Id, TimeSpan.Zero);
        Assert.IsNotNull(main);
        missing = main.WikiLinks.FirstOrDefault(x => x.Missing);
        Assert.IsNull(missing);

        category = dataStore.GetItem <Category>(category.Id, TimeSpan.Zero);
        Assert.IsNotNull(main);
        missing = main.WikiLinks.FirstOrDefault(x => x.Missing);
        Assert.IsNull(missing);

        Assert.AreEqual(_ExpectedAbout, about.Html, ignoreCase: false);
    }