14
14
[ TestFixture ]
15
15
public class DocumentationTests
16
16
{
17
+ private DirectoryInfo docsDirectory ;
18
+
19
+ [ OneTimeSetUp ]
20
+ public void OneTimeSetUp ( )
21
+ {
22
+ docsDirectory = GetDocsDirectory ( ) ;
23
+ }
24
+
17
25
[ Test ]
18
26
public void ConfigurationDocumentationIsUpToDate ( )
19
27
{
@@ -54,8 +62,44 @@ public void VariableDocumentationIsUpToDate()
54
62
}
55
63
}
56
64
65
+ [ Test ]
66
+ public void DocumentationIndexIsUpToDate ( )
67
+ {
68
+ var documentationIndexFile = ReadDocumentationFile ( "../mkdocs.yml" ) ;
69
+ var docsDirectoryPath = new Uri ( docsDirectory . FullName , UriKind . Absolute ) ;
70
+
71
+ Console . WriteLine ( docsDirectoryPath ) ;
72
+
73
+ foreach ( var markdownFile in docsDirectory . EnumerateFiles ( "*.md" , SearchOption . AllDirectories ) )
74
+ {
75
+ var fullPath = new Uri ( markdownFile . FullName , UriKind . Absolute ) ;
76
+ var relativePath = docsDirectoryPath
77
+ . MakeRelativeUri ( fullPath )
78
+ . ToString ( )
79
+ . Replace ( "docs/" , string . Empty ) ;
80
+
81
+ Console . WriteLine ( fullPath ) ;
82
+ Console . WriteLine ( relativePath ) ;
83
+
84
+ documentationIndexFile . ShouldContain ( relativePath , ( ) => string . Format ( "The file '{0}' is not listed in 'mkdocs.yml'." , relativePath ) ) ;
85
+ }
86
+ }
87
+
88
+ private string ReadDocumentationFile ( string relativeDocumentationFilePath )
89
+ {
90
+ var documentationFilePath = Path . Combine ( docsDirectory . FullName , relativeDocumentationFilePath ) ;
91
+ // Normalize path separators and such.
92
+ documentationFilePath = new FileInfo ( documentationFilePath ) . FullName ;
93
+
94
+ if ( ! File . Exists ( documentationFilePath ) )
95
+ {
96
+ throw new FileNotFoundException ( string . Format ( "The documentation file '{0}' couldn't be found." , documentationFilePath ) , documentationFilePath ) ;
97
+ }
57
98
58
- static string ReadDocumentationFile ( string relativeDocumentationFilePath )
99
+ return File . ReadAllText ( documentationFilePath ) ;
100
+ }
101
+
102
+ private static DirectoryInfo GetDocsDirectory ( )
59
103
{
60
104
var currentDirectory = new FileInfo ( typeof ( DocumentationTests ) . Assembly . Location ) . Directory ;
61
105
while ( currentDirectory != null )
@@ -78,15 +122,6 @@ static string ReadDocumentationFile(string relativeDocumentationFilePath)
78
122
throw new DirectoryNotFoundException ( "Couldn't find the 'docs' directory." ) ;
79
123
}
80
124
81
- var documentationFilePath = Path . Combine ( currentDirectory . FullName , relativeDocumentationFilePath ) ;
82
- // Normalize path separators and such.
83
- documentationFilePath = new FileInfo ( documentationFilePath ) . FullName ;
84
-
85
- if ( ! File . Exists ( documentationFilePath ) )
86
- {
87
- throw new FileNotFoundException ( string . Format ( "The documentation file '{0}' couldn't be found." , documentationFilePath ) , documentationFilePath ) ;
88
- }
89
-
90
- return File . ReadAllText ( documentationFilePath ) ;
125
+ return currentDirectory ;
91
126
}
92
127
}
0 commit comments