Repository navigation
Expand file tree
/
Copy pathAddShellDocsTests.cs
More file actions
59 lines (49 loc) · 1.9 KB
/
Copy pathAddShellDocsTests.cs
File metadata and controls
59 lines (49 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Microsoft.Extensions.DependencyInjection;
using ShellDocs.Components;
using ShellDocs.Core;
using ShellDocs.Markdown;
using Xunit;
namespace ShellDocs.Tests;
public class AddShellDocsTests
{
[Fact]
public void AddShellDocs_RegistersCoreServices()
{
var services = new ServiceCollection();
services.AddShellDocs(o => o.SiteName = "Test");
var sp = services.BuildServiceProvider();
Assert.NotNull(sp.GetService<ShellDocsOptions>());
Assert.NotNull(sp.GetService<TypeRegistry>());
Assert.NotNull(sp.GetService<MarkdownRenderer>());
Assert.NotNull(sp.GetService<NavigationGraph>());
}
[Fact]
public void AddShellDocs_MissingContentRoot_ReturnsEmptyGraph()
{
var services = new ServiceCollection();
services.AddShellDocs(o => o.ContentRoot = "does-not-exist-" + Guid.NewGuid().ToString("N"));
var sp = services.BuildServiceProvider();
var graph = sp.GetRequiredService<NavigationGraph>();
Assert.Empty(graph.Root.Children);
}
[Fact]
public void AddShellDocs_RegisteredComponents_FlowIntoTypeRegistry()
{
var services = new ServiceCollection();
services.AddShellDocs(o => o.RegisterComponent<CustomWidget>());
var sp = services.BuildServiceProvider();
var registry = sp.GetRequiredService<TypeRegistry>();
Assert.Equal(typeof(CustomWidget), registry.Resolve("CustomWidget"));
}
[Fact]
public void ShellDocsOptions_FluentAddNavLink_AppendsInOrder()
{
var options = new ShellDocsOptions()
.AddNavLink("Docs", "/docs")
.AddNavLink("Blog", "/blog");
Assert.Equal(2, options.PrimaryNav.Count);
Assert.Equal("Docs", options.PrimaryNav[0].Label);
Assert.Equal("/blog", options.PrimaryNav[1].Href);
}
public class CustomWidget : Microsoft.AspNetCore.Components.ComponentBase { }
}