Skip to content

Commit

Permalink
.NET 6
Browse files Browse the repository at this point in the history
  • Loading branch information
WilStead committed Aug 31, 2021
1 parent f9e8ef0 commit 8ea00be
Show file tree
Hide file tree
Showing 42 changed files with 9,069 additions and 9,612 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: publish
env:
VERSION: '0.3.2-preview'
VERSION: '0.4.0-preview'
PRERELEASE: true
on:
push:
Expand All @@ -12,11 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setup .NET 5
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
# Semantic version range syntax or exact version of a dotnet version
dotnet-version: '5.0.x'
dotnet-version: '6.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore
Expand Down
140 changes: 68 additions & 72 deletions Test/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,57 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using System.Threading.Tasks;
using Tavenem.DataStorage;

namespace Tavenem.Wiki.Test
namespace Tavenem.Wiki.Test;

[TestClass]
public class IntegrationTests
{
[TestClass]
public class IntegrationTests
{
private const string ExpectedWelcome = "<p>Welcome to the <a href=\"https://github.com/Tavenem/Wiki\">Tavenem.Wiki</a> sample.</p>\n<p></p>\n";
private const string ExpectedWelcomeTransclusion = @"Welcome to the <a href=""https://github.com/Tavenem/Wiki"">Tavenem.Wiki</a> sample.";
private const string ExpectedWelcome = "<p>Welcome to the <a href=\"https://github.com/Tavenem/Wiki\">Tavenem.Wiki</a> sample.</p>\n<p></p>\n";
private const string ExpectedWelcomeTransclusion = @"Welcome to the <a href=""https://github.com/Tavenem/Wiki"">Tavenem.Wiki</a> sample.";

private static readonly string _ExpectedAbout = $"<p>{ExpectedWelcomeTransclusion}</p>\n<p>The <a href=\"https://github.com/Tavenem/Wiki\">Tavenem.Wiki</a> package is a <a href=\"https://dotnet.microsoft.com\">.NET</a> <a href=\"https://wikipedia.org/wiki/Wiki\">wiki</a> library.</p>\n<p>Unlike many wiki implementations, the main package (<code>Tavenem.Wiki</code>) is implementation-agnostic. It provides a set of core features which can be used to build a web-based wiki, a desktop application, a distributed cloud app with native clients, or any other architecture desired.</p>\n<p>See the <a href=\"/Wiki/System:Help\" class=\"wiki-link-missing\">Help</a> page for usage information.</p>\n<p></p>\n";
private static readonly string _ExpectedAbout = $"<p>{ExpectedWelcomeTransclusion}</p>\n<p>The <a href=\"https://github.com/Tavenem/Wiki\">Tavenem.Wiki</a> package is a <a href=\"https://dotnet.microsoft.com\">.NET</a> <a href=\"https://wikipedia.org/wiki/Wiki\">wiki</a> library.</p>\n<p>Unlike many wiki implementations, the main package (<code>Tavenem.Wiki</code>) is implementation-agnostic. It provides a set of core features which can be used to build a web-based wiki, a desktop application, a distributed cloud app with native clients, or any other architecture desired.</p>\n<p>See the <a href=\"/Wiki/System:Help\" class=\"wiki-link-missing\">Help</a> page for usage information.</p>\n<p></p>\n";

[TestMethod]
public void CreateWikiTest()
{
const string AdminId = "AdminId";
[TestMethod]
public void CreateWikiTest()
{
const string AdminId = "AdminId";

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

var welcome = GetDefaultWelcomeAsync(options, dataStore, AdminId).GetAwaiter().GetResult();
Assert.AreEqual(ExpectedWelcome, welcome.Html, ignoreCase: false);
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 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 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();
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);
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);
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);
}
Assert.AreEqual(_ExpectedAbout, about.Html, ignoreCase: false);
}

private static Task<Article> GetDefaultAboutAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
"About",
adminId,
private static Task<Article> GetDefaultAboutAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
"About",
adminId,
@$"{{{{Welcome}}}}
The [Tavenem.Wiki](https://github.com/Tavenem/Wiki) package is a [.NET](https://dotnet.microsoft.com) [[w:Wiki||]] library.
Expand All @@ -64,42 +61,41 @@ The [Tavenem.Wiki](https://github.com/Tavenem/Wiki) package is a [.NET](https://
See the [[System:Help|]] page for usage information.
[[{options.CategoryNamespace}:System pages]]",
"System",
adminId,
new[] { adminId });

private static Task<Article> GetDefaultMainAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
options.MainPageTitle,
adminId,
"System",
adminId,
new[] { adminId });

private static Task<Article> GetDefaultMainAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
options.MainPageTitle,
adminId,
@$"{{{{Welcome}}}}
See the [[System:About|]] page for more information.
[[{options.CategoryNamespace}:System pages]]",
options.DefaultNamespace,
adminId,
new[] { adminId });

private static Task<Article> GetDefaultWelcomeAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
"Welcome",
adminId,
options.DefaultNamespace,
adminId,
new[] { adminId });

private static Task<Article> GetDefaultWelcomeAsync(IWikiOptions options, IDataStore dataStore, string adminId) => Article.NewAsync(
options,
dataStore,
"Welcome",
adminId,
@$"Welcome to the [Tavenem.Wiki](https://github.com/Tavenem/Wiki) sample.
{{{{ifnottemplate|[[{options.CategoryNamespace}:System pages]]}}}}",
options.TransclusionNamespace,
adminId,
new[] { adminId });

private static Task SetDefaultCategoryAsync(IWikiOptions options, IDataStore dataStore, Category category, string adminId) => category.ReviseAsync(
options,
dataStore,
adminId,
markdown: "These are system pages in the [Tavenem.Wiki](https://github.com/Tavenem/Wiki) sample [[w:Wiki||]]. [[System:About|]]",
revisionComment: "Provide a description",
allowedEditors: new[] { adminId });
}
options.TransclusionNamespace,
adminId,
new[] { adminId });

private static Task SetDefaultCategoryAsync(IWikiOptions options, IDataStore dataStore, Category category, string adminId) => category.ReviseAsync(
options,
dataStore,
adminId,
markdown: "These are system pages in the [Tavenem.Wiki](https://github.com/Tavenem/Wiki) sample [[w:Wiki||]]. [[System:About|]]",
revisionComment: "Provide a description",
allowedEditors: new[] { adminId });
}
Loading

0 comments on commit 8ea00be

Please sign in to comment.