public void GlobalSetup() { _useExportProviderAttribute.Before(null); if (_workspace != null) { throw new InvalidOperationException(); } _workspace = TestWorkspace.Create( @"<Workspace> <Project Language=""NoCompilation"" CommonReferences=""false""> <Document> // a no-compilation document </Document> </Project> </Workspace>" ); // Explicitly choose the sqlite db to test. _workspace.TryApplyChanges( _workspace.CurrentSolution.WithOptions( _workspace.Options.WithChangedOption( StorageOptions.Database, StorageDatabase.SQLite ) ) ); var connectionPoolService = _workspace.ExportProvider.GetExportedValue <SQLiteConnectionPoolService>(); _storageService = new SQLitePersistentStorageService( connectionPoolService, new LocationService() ); var solution = _workspace.CurrentSolution; _storage = _storageService .GetStorageWorkerAsync( _workspace, SolutionKey.ToSolutionKey(solution), solution, CancellationToken.None ) .AsTask() .GetAwaiter() .GetResult(); if (_storage == NoOpPersistentStorage.Instance) { throw new InvalidOperationException( "We didn't properly get the sqlite storage instance." ); } Console.WriteLine("Storage type: " + _storage.GetType()); _document = _workspace.CurrentSolution.Projects.Single().Documents.Single(); _random = new Random(0); }
public void GlobalSetup() { _useExportProviderAttribute.Before(null); if (_workspace != null) { throw new InvalidOperationException(); } _workspace = TestWorkspace.Create( @"<Workspace> <Project Language=""NoCompilation"" CommonReferences=""false""> <Document> // a no-compilation document </Document> </Project> </Workspace>"); var connectionPoolService = _workspace.ExportProvider.GetExportedValue <SQLiteConnectionPoolService>(); var asyncListener = _workspace.ExportProvider.GetExportedValue <IAsynchronousOperationListenerProvider>().GetListener(FeatureAttribute.PersistentStorage); _storageService = new SQLitePersistentStorageService(connectionPoolService, new StorageConfiguration(), asyncListener); var solution = _workspace.CurrentSolution; _storage = _storageService.GetStorageWorkerAsync(SolutionKey.ToSolutionKey(solution), CancellationToken.None).AsTask().GetAwaiter().GetResult(); Console.WriteLine("Storage type: " + _storage.GetType()); _document = _workspace.CurrentSolution.Projects.Single().Documents.Single(); _random = new Random(0); }
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { var optionService = workspaceServices.GetRequiredService <IOptionService>(); var database = optionService.GetOption(StorageOptions.Database); switch (database) { case StorageDatabase.SQLite: if (!SQLitePersistentStorageService.TryInitializeLibraries()) { break; } var locationService = workspaceServices.GetService <IPersistentStorageLocationService>(); if (locationService != null) { return(new SQLitePersistentStorageService(optionService, locationService, _solutionSizeTracker)); } break; } return(NoOpPersistentStorageService.Instance); }
public SQLitePersistentStorageBenchmarks() { _document = null !; _storage = null !; _storageService = null !; _workspace = null !; _random = null !; }
public void GlobalCleanup() { if (_workspace == null) { throw new InvalidOperationException(); } _document = null; _storage.Dispose(); _storage = null; _storageService = null; _workspace.Dispose(); _workspace = null; _useExportProviderAttribute.After(null); }
public void GlobalSetup() { _useExportProviderAttribute.Before(null); if (_workspace != null) { throw new InvalidOperationException(); } _workspace = TestWorkspace.Create( @"<Workspace> <Project Language=""NoCompilation"" CommonReferences=""false""> <Document> // a no-compilation document </Document> </Project> </Workspace>"); // Ensure we always use the storage service, no matter what the size of the solution. _workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions( _workspace.CurrentSolution.Options.WithChangedOption(StorageOptions.SolutionSizeThreshold, -1))); _storageService = new SQLitePersistentStorageService( _workspace.Services.GetService <IOptionService>(), new LocationService(), new SolutionSizeTracker()); _storage = _storageService.GetStorageWorker(_workspace.CurrentSolution); if (_storage == NoOpPersistentStorage.Instance) { throw new InvalidOperationException("We didn't properly get the sqlite storage instance."); } Console.WriteLine("Storage type: " + _storage.GetType()); _document = _workspace.CurrentSolution.Projects.Single().Documents.Single(); _random = new Random(0); }
static SQLitePersistentStorageTests() { Assert.True(SQLitePersistentStorageService.TryInitializeLibraries()); }