public async Task GetSwaggerDocumentAsync_ReturnsNull_WhenFileIsNotPresent() { using (var directory = new TempDirectory()) { JObject emptyObject = null; _scriptConfig.RootScriptPath = directory.Path; var swaggerDocumentManager = new SwaggerDocumentManager(_scriptConfig); var document = await swaggerDocumentManager.GetSwaggerDocumentAsync(); Assert.Equal(emptyObject, document); } }
public async Task GetSwaggerDocumentAsync_ReturnsSwaggerDocument() { using (var directory = new TempDirectory()) using (var systemDirectoryName = new TempDirectory(Path.Combine(directory.Path, ScriptConstants.AzureFunctionsSystemDirectoryName))) using (var swaggerDirectoryName = new TempDirectory(Path.Combine(systemDirectoryName.Path, ScriptConstants.SwaggerDirectoryName))) { string swaggerDocument = @"{}"; File.WriteAllText(Path.Combine(swaggerDirectoryName.Path, ScriptConstants.SwaggerFileName), swaggerDocument); _scriptConfig.RootScriptPath = directory.Path; var swaggerDocumentManager = new SwaggerDocumentManager(_scriptConfig); var document = await swaggerDocumentManager.GetSwaggerDocumentAsync(); Assert.Equal(JObject.Parse(swaggerDocument), document); } }