|
1 | | -namespace Ditto.Tests; |
2 | | - |
3 | | -public sealed class PageFileLoaderTests { |
4 | | - [Fact] |
5 | | - public void LoadFiles_ReturnsPageFiles_WhenValidInput() { |
6 | | - var pageFileLoader = new PageFileLoader(Shared.BasePath, Shared.OutputPath); |
7 | | - var pageFiles = pageFileLoader.LoadFiles(); |
8 | | - |
9 | | - Assert.NotNull(pageFiles); |
10 | | - Assert.NotEmpty(pageFiles); |
11 | | - Assert.Equal(5, pageFiles.Count); |
12 | | - Assert.All(pageFiles, pageFile => { |
13 | | - Assert.NotNull(pageFile.InputPath); |
14 | | - Assert.NotNull(pageFile.OutputPath); |
15 | | - Assert.NotNull(pageFile.Path); |
16 | | - Assert.NotNull(pageFile.PageName); |
17 | | - |
18 | | - Assert.True(File.Exists(pageFile.InputPath)); |
19 | | - Assert.Equal("index.html", Path.GetFileName(pageFile.OutputPath)); // every page file should be named index.html |
20 | | - // Assert.Contains(pageFile.PageName, pageFile.OutputPath); |
21 | | - |
22 | | - if (Path.GetRelativePath(Shared.BasePath, pageFile.InputPath) == "index.html") { |
23 | | - // the index page should map to the output path directly |
24 | | - Assert.Equal("index.html", Path.GetRelativePath(Shared.OutputPath, pageFile.OutputPath)); |
25 | | - } |
26 | | - }); |
27 | | - } |
28 | | -} |
29 | | - |
30 | | -public sealed class PageFileHelperTests { |
31 | | - [Theory] |
32 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\index.html", "/")] |
33 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\about.html", "/about/")] |
34 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\blog\post1.html", "/blog/post1/")] |
35 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/index.html", "/")] |
36 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/about.html", "/about/")] |
37 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/blog/post1.html", "/blog/post1/")] |
38 | | - public void GetPath_ReturnsExpectedPath(string basePath, string filePath, string expectedPath) { |
39 | | - Assert.Equal(expectedPath, PageFileHelper.GetPath(basePath, filePath)); |
40 | | - } |
41 | | - |
42 | | - [Theory] |
43 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\index.html", "index")] |
44 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\about.html", "about")] |
45 | | - [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\blog\post1.html", "blog/post1")] |
46 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/index.html", "index")] |
47 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/about.html", "about")] |
48 | | - [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/blog/post1.html", "blog/post1")] |
49 | | - public void GetPageName_ReturnsExpected(string basePath, string filePath, string expected) { |
50 | | - Assert.Equal(expected, PageFileHelper.GetPageName(basePath, filePath)); |
51 | | - } |
52 | | - |
53 | | - [Theory] |
54 | | - [InlineData("about.md", ViewType.Markdown)] |
55 | | - [InlineData("contact.html", ViewType.Html)] |
56 | | - public void GetViewType_ReturnsExpectedViewType(string fileName, ViewType expectedViewType) { |
57 | | - var viewType = PageFileHelper.GetViewType(fileName); |
58 | | - Assert.Equal(expectedViewType, viewType); |
59 | | - } |
60 | | -} |
| 1 | +namespace Ditto.Tests; |
| 2 | + |
| 3 | +public sealed class PageFileLoaderTests { |
| 4 | + [Fact] |
| 5 | + public void LoadFiles_ReturnsPageFiles_WhenValidInput() { |
| 6 | + var pageFileLoader = new PageFileLoader(Shared.BasePath, Shared.OutputPath); |
| 7 | + var pageFiles = pageFileLoader.LoadFiles(); |
| 8 | + |
| 9 | + Assert.NotNull(pageFiles); |
| 10 | + Assert.NotEmpty(pageFiles); |
| 11 | + Assert.Equal(5, pageFiles.Count); |
| 12 | + Assert.All(pageFiles, pageFile => { |
| 13 | + Assert.NotNull(pageFile.InputPath); |
| 14 | + Assert.NotNull(pageFile.OutputPath); |
| 15 | + Assert.NotNull(pageFile.Path); |
| 16 | + Assert.NotNull(pageFile.PageName); |
| 17 | + |
| 18 | + Assert.True(File.Exists(pageFile.InputPath)); |
| 19 | + Assert.Equal("index.html", Path.GetFileName(pageFile.OutputPath)); // every page file should be named index.html |
| 20 | + // Assert.Contains(pageFile.PageName, pageFile.OutputPath); |
| 21 | + |
| 22 | + if (Path.GetRelativePath(Shared.BasePath, pageFile.InputPath) == "index.html") { |
| 23 | + // the index page should map to the output path directly |
| 24 | + Assert.Equal("index.html", Path.GetRelativePath(Shared.OutputPath, pageFile.OutputPath)); |
| 25 | + } |
| 26 | + }); |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +public sealed class PageFileHelperTests { |
| 31 | + [Theory] |
| 32 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\index.html", "/")] |
| 33 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\about.html", "/about/")] |
| 34 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\blog\post1.html", "/blog/post1/")] |
| 35 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/index.html", "/")] |
| 36 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/about.html", "/about/")] |
| 37 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/blog/post1.html", "/blog/post1/")] |
| 38 | + public void GetPath_ReturnsExpectedPath(string basePath, string filePath, string expectedPath) { |
| 39 | + Assert.Equal(expectedPath, PageFileHelper.GetPath(basePath, filePath)); |
| 40 | + } |
| 41 | + |
| 42 | + [Theory] |
| 43 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\index.html", "index")] |
| 44 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\about.html", "about")] |
| 45 | + [InlineData(@"C:\users\ditto\website\src", @"C:\users\ditto\website\src\blog\post1.html", "blog/post1")] |
| 46 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/index.html", "index")] |
| 47 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/about.html", "about")] |
| 48 | + [InlineData(@"/users/ditto/website/src", @"/users/ditto/website/src/blog/post1.html", "blog/post1")] |
| 49 | + public void GetPageName_ReturnsExpected(string basePath, string filePath, string expected) { |
| 50 | + Assert.Equal(expected, PageFileHelper.GetPageName(basePath, filePath)); |
| 51 | + } |
| 52 | + |
| 53 | + [Theory] |
| 54 | + [InlineData("about.md", ViewType.Markdown)] |
| 55 | + [InlineData("contact.html", ViewType.Html)] |
| 56 | + [InlineData("post", ViewType.Html)] |
| 57 | + public void GetViewType_ReturnsExpectedViewType(string fileName, ViewType expectedViewType) { |
| 58 | + Assert.Equal(expectedViewType, PageFileHelper.GetViewType(fileName)); |
| 59 | + } |
| 60 | +} |
0 commit comments