Skip to content

Commit ff8ede4

Browse files
BenjaminMichaelisJoshua-Lester3
authored andcommitted
WIP
1 parent 23ff1d6 commit ff8ede4

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

EssentialCSharp.Web.Tests/SiteMappingTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace EssentialCSharp.Web.Tests;
55
public class SiteMappingTests
66
{
77
static SiteMapping HelloWorldSiteMapping => new(
8-
key: "hello-world",
8+
keys: ["hello-world"],
99
pagePath:
1010
[
1111
"Chapters",
@@ -22,7 +22,7 @@ public class SiteMappingTests
2222
);
2323

2424
static SiteMapping CSyntaxFundamentalsSiteMapping => new(
25-
key: "c-syntax-fundamentals",
25+
keys: ["c-syntax-fundamentals"],
2626
pagePath:
2727
[
2828
"Chapters",
@@ -52,30 +52,30 @@ public void FindHelloWorldWithAnchorSlugReturnsCorrectSiteMap()
5252
{
5353
SiteMapping? foundSiteMap = GetSiteMap().Find("hello-world#hello-world");
5454
Assert.NotNull(foundSiteMap);
55-
Assert.Equal(HelloWorldSiteMapping, foundSiteMap);
55+
Assert.Equivalent(HelloWorldSiteMapping, foundSiteMap);
5656
}
5757

5858
[Fact]
5959
public void FindCSyntaxFundamentalsWithSpacesReturnsCorrectSiteMap()
6060
{
6161
SiteMapping? foundSiteMap = GetSiteMap().Find("C# Syntax Fundamentals");
6262
Assert.NotNull(foundSiteMap);
63-
Assert.Equal(CSyntaxFundamentalsSiteMapping, foundSiteMap);
63+
Assert.Equivalent(CSyntaxFundamentalsSiteMapping, foundSiteMap);
6464
}
6565

6666
[Fact]
6767
public void FindCSyntaxFundamentalsWithSpacesAndAnchorReturnsCorrectSiteMap()
6868
{
6969
SiteMapping? foundSiteMap = GetSiteMap().Find("C# Syntax Fundamentals#hello-world");
7070
Assert.NotNull(foundSiteMap);
71-
Assert.Equal(CSyntaxFundamentalsSiteMapping, foundSiteMap);
71+
Assert.Equivalent(CSyntaxFundamentalsSiteMapping, foundSiteMap);
7272
}
7373

7474
[Fact]
7575
public void FindCSyntaxFundamentalsSanitizedWithAnchorReturnsCorrectSiteMap()
7676
{
7777
SiteMapping? foundSiteMap = GetSiteMap().Find("c-syntax-fundamentals#hello-world");
7878
Assert.NotNull(foundSiteMap);
79-
Assert.Equal(CSyntaxFundamentalsSiteMapping, foundSiteMap);
79+
Assert.Equivalent(CSyntaxFundamentalsSiteMapping, foundSiteMap);
8080
}
8181
}

EssentialCSharp.Web/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private string FlipPage(int currentChapter, int currentPage, bool next)
125125
return "";
126126
}
127127
}
128-
return $"{siteMap.Key}#{siteMap.AnchorId}";
128+
return $"{siteMap.Keys.First()}#{siteMap.AnchorId}";
129129
}
130130

131131
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

EssentialCSharp.Web/Extensions/SiteMappingListExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class SiteMappingListExtensions
1616
}
1717
foreach (string? potentialMatch in key.GetPotentialMatches())
1818
{
19-
if (siteMappings.FirstOrDefault(x => x.Key == potentialMatch) is { } siteMap)
19+
if (siteMappings.FirstOrDefault(x => x.Keys.Any(x => x == potentialMatch)) is { } siteMap)
2020
{
2121
return siteMap;
2222
}

EssentialCSharp.Web/Views/Shared/_Layout.cshtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,18 @@
277277
.Select(i => new
278278
{
279279
Level = indentLevel,
280-
Key = i.Key,
281-
Href = $"{i.Key}#{i.AnchorId}",
280+
Key = i.Keys.First(),
281+
Href = $"{i.Keys.First()}#{i.AnchorId}",
282282
Title = i.RawHeading,
283283
// Any children of this node will be /after/ this node,
284284
// so skip any items that are /before/ the current node.
285-
Items = GetItems(chapterItems.SkipWhile(q => i.Key != q.Key), indentLevel + 1)
285+
Items = GetItems(chapterItems.SkipWhile(q => i.Keys.First() != q.Keys.First()), indentLevel + 1)
286286
});
287287
var tocData = _SiteMappings.SiteMappings.GroupBy(x => x.ChapterNumber).OrderBy(x => x.Key).Select(x => new
288288
{
289289
Level = 0,
290-
Key = x.First().Key,
291-
Href = $"{x.First().Key}#{x.First().AnchorId}",
290+
Key = x.First().Keys.First(),
291+
Href = $"{x.First().Keys.First()}#{x.First().AnchorId}",
292292
Title = $"Chapter {x.Key}: {x.First().ChapterTitle}",
293293
Items = GetItems(x, 1)
294294
});

0 commit comments

Comments
 (0)