public void FilesLocator_Throws_When_No_SearchPaths_Does_Not_Exist() { FilesLocator locator = new FilesLocator(new MockFileSystem()); var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One", @"C:\Two" })); Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message); }
public void FilesLocator_Throws_When_No_SearchPaths_Does_Not_Exist() { FilesLocator locator = new FilesLocator(new MockFileSystem()); var ex = Assert.Throws <InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One", @"C:\Two" })); Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message); }
public void FilesLocator_Throws_When_No_Matches_In_SearchPaths() { MockFileSystem fs = new MockFileSystem(); var folders = new[] { @"C:\One", @"C:\Two" }; fs.AddFolders(folders); fs.WriteAllText(@"C:\One\template1.cshtml", ""); fs.WriteAllText(@"C:\Two\template2.cshtml", ""); FilesLocator locator = new FilesLocator(fs); var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", folders)); Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message); }
public void FilesLocator_Throws_When_Multiple_Matches_In_OneSearchPath() { MockFileSystem fs = new MockFileSystem(); var folders = new[] { @"C:\One", @"C:\One\Sub1", @"C:\One\Sub2" }; fs.AddFolders(folders); fs.WriteAllText(@"C:\One\Sub1\template.cshtml", ""); fs.WriteAllText(@"C:\One\Sub2\template.cshtml", ""); FilesLocator locator = new FilesLocator(fs); var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One" })); Assert.Equal(@"Multiple files with name template.cshtml found within C:\One", ex.Message); }
public void FilesLocator_Returns_Entry_From_FirstSearchPath() { MockFileSystem fs = new MockFileSystem(); var folders = new[] { @"C:\One", @"C:\Two" }; fs.AddFolders(folders); fs.WriteAllText(@"C:\One\template.cshtml", ""); fs.WriteAllText(@"C:\Two\template.cshtml", ""); FilesLocator locator = new FilesLocator(fs); var result = locator.GetFilePath("template.cshtml", folders); Assert.Equal(@"C:\One\template.cshtml", result); }
public void FilesLocator_Throws_When_No_Matches_In_SearchPaths() { MockFileSystem fs = new MockFileSystem(); var folders = new[] { @"C:\One", @"C:\Two" }; fs.AddFolders(folders); fs.WriteAllText(@"C:\One\template1.cshtml", ""); fs.WriteAllText(@"C:\Two\template2.cshtml", ""); FilesLocator locator = new FilesLocator(fs); var ex = Assert.Throws <InvalidOperationException>(() => locator.GetFilePath("template.cshtml", folders)); Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message); }
public void FilesLocator_Throws_When_Multiple_Matches_In_OneSearchPath() { MockFileSystem fs = new MockFileSystem(); var folders = new[] { @"C:\One", @"C:\One\Sub1", @"C:\One\Sub2" }; fs.AddFolders(folders); fs.WriteAllText(@"C:\One\Sub1\template.cshtml", ""); fs.WriteAllText(@"C:\One\Sub2\template.cshtml", ""); FilesLocator locator = new FilesLocator(fs); var ex = Assert.Throws <InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One" })); Assert.Equal(@"Multiple files with name template.cshtml found within C:\One", ex.Message); }
private EntityFrameworkServices GetEfServices(string path, string applicationName, bool useSqlite) { _appInfo = new ApplicationInfo(applicationName, Path.GetDirectoryName(path), "Debug"); _logger = new ConsoleLogger(); _packageInstaller = new Mock <IPackageInstaller>(); _serviceProvider = new Mock <IServiceProvider>(); _projectContext = GetProjectInformation(path); _workspace = new RoslynWorkspace(_projectContext); _loader = new TestAssemblyLoadContext(_projectContext); _modelTypesLocator = new ModelTypesLocator(_workspace); var dbContextMock = new Mock <IDbContextEditorServices>(); var editSyntaxTreeResult = new EditSyntaxTreeResult() { Edited = true }; dbContextMock.Setup(db => db.EditStartupForNewContext(It.IsAny <ModelType>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), useSqlite)) .Returns(editSyntaxTreeResult); var connectionStringsWriter = new Mock <IConnectionStringsWriter>(); connectionStringsWriter.Setup(c => c.AddConnectionString(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())); var filesLocator = new FilesLocator(); var compilationService = new RoslynCompilationService(_appInfo, _loader, _projectContext); var templatingService = new Templating.RazorTemplating(compilationService); _dbContextEditorServices = new DbContextEditorServices(_projectContext, _appInfo, filesLocator, templatingService, connectionStringsWriter.Object); return(new EntityFrameworkServices( _projectContext, _appInfo, _loader, _modelTypesLocator, _dbContextEditorServices, _packageInstaller.Object, _serviceProvider.Object, _workspace, DefaultFileSystem.Instance, _logger)); }
public static CodeGeneratorActionsService CodeGeneratorActionsService(ProjectContext project) { IFilesLocator files = new FilesLocator(); return(new CodeGeneratorActionsService(new RazorTemplating(project), files)); }