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); }