19
19
[ TestClass ]
20
20
public class CatalogManagerTests
21
21
{
22
+ private Mock < IDirectoryIO > mockDirectory ;
22
23
private Mock < IFileSystem > mockFileSystem ;
23
24
private Microsoft . Extensions . Logging . ILogger logger ;
24
25
private Mock < IGitHubService > mockGitHubService ;
25
26
private CatalogManager catalogManager ;
26
27
private const string workspace = "testWorkspace" ;
27
28
private const string catalogFilePath = "testWorkspace/catalog.yml" ;
28
29
private const string manifestFilePath = "testWorkspace/manifest.yml" ;
30
+ private const string autoGeneratorFilePath = "testWorkspace/.githubtocatalog/auto-generated-catalog.yml" ;
29
31
30
32
[ TestInitialize ]
31
33
public void Setup ( )
@@ -43,6 +45,12 @@ public void Setup()
43
45
44
46
mockFileSystem . Setup ( fs => fs . Path . Combine ( workspace , "catalog.yml" ) ) . Returns ( catalogFilePath ) ;
45
47
mockFileSystem . Setup ( fs => fs . Path . Combine ( workspace , "manifest.yml" ) ) . Returns ( manifestFilePath ) ;
48
+ mockFileSystem . Setup ( fs => fs . Path . Combine ( workspace , ".githubtocatalog" , "auto-generated-catalog.yml" ) ) . Returns ( autoGeneratorFilePath ) ;
49
+
50
+ mockDirectory = new Mock < IDirectoryIO > ( ) ;
51
+ mockDirectory . Setup ( dir => dir . CreateDirectory ( It . IsAny < string > ( ) ) ) ;
52
+
53
+ mockFileSystem . Setup ( fs => fs . Directory ) . Returns ( mockDirectory . Object ) ;
46
54
47
55
catalogManager = new CatalogManager ( mockFileSystem . Object , logger , mockGitHubService . Object , workspace ) ;
48
56
}
@@ -256,10 +264,10 @@ public async Task ProcessCatalogYamlAsync_ShouldLogInformationMessage_WhenProces
256
264
257
265
mockFileSystem . Setup ( fs => fs . Path . Combine ( workspace , "catalog.yml" ) ) . Returns ( catalogFilePath ) ;
258
266
mockFileSystem . Setup ( fs => fs . Path . Combine ( workspace , "manifest.yml" ) ) . Returns ( manifestFilePath ) ;
267
+ mockFileSystem . Setup ( fs => fs . Directory . CreateDirectory ( It . IsAny < string > ( ) ) ) ;
259
268
260
269
catalogManager = new CatalogManager ( mockFileSystem . Object , mockLogger . Object , mockGitHubService . Object , workspace ) ;
261
270
262
-
263
271
var repoName = "SLC-AS-testRepo" ;
264
272
var yamlContent = "id: testId\n title: ExistingTitle\n short_description: test description\n tags: [testTag]" ;
265
273
mockFileSystem . Setup ( fs => fs . File . Exists ( catalogFilePath ) ) . Returns ( true ) ; // catalog.yml exists
0 commit comments