Ejemplo n.º 1
0
 private CodeModelService GetCodeModelService(string path, string applicationName)
 {
     _appInfo           = new ApplicationInfo(applicationName, Path.GetDirectoryName(path), "Debug");
     _logger            = new ConsoleLogger();
     _projectContext    = GetProjectInformation(path);
     _workspace         = new RoslynWorkspace(_projectContext);
     _loader            = new TestAssemblyLoadContext(_projectContext);
     _modelTypesLocator = new ModelTypesLocator(_workspace);
     return(new CodeModelService(_projectContext, _workspace, _logger, _loader));
 }
Ejemplo n.º 2
0
        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));
        }