internal IChecksummedPersistentStorage GetStorage(
            Solution solution, IPersistentStorageFaultInjector?faultInjector = null)
        {
            // If we handed out one for a previous test, we need to shut that down first
            _storageService?.GetTestAccessor().Shutdown();
            var locationService = new MockPersistentStorageLocationService(solution.Id, _persistentFolder.Path);

            _storageService = GetStorageService((IMefHostExportProvider)solution.Workspace.Services.HostServices, locationService, faultInjector);
            var storage = _storageService.GetStorage(solution, checkBranchId: true);

            // If we're injecting faults, we expect things to be strange
            if (faultInjector == null)
            {
                Assert.NotEqual(NoOpPersistentStorage.Instance, storage);
            }

            return(storage);
        }
示例#2
0
        internal async Task <IChecksummedPersistentStorage> GetStorageFromKeyAsync(
            Workspace workspace, SolutionKey solutionKey, IPersistentStorageFaultInjector?faultInjector = null)
        {
            // If we handed out one for a previous test, we need to shut that down first
            _storageService?.GetTestAccessor().Shutdown();
            var locationService = new MockPersistentStorageLocationService(solutionKey.Id, _persistentFolder.Path);

            _storageService = GetStorageService((IMefHostExportProvider)workspace.Services.HostServices, locationService, faultInjector);
            var storage = await _storageService.GetStorageAsync(workspace, solutionKey, checkBranchId : true, CancellationToken.None);

            // If we're injecting faults, we expect things to be strange
            if (faultInjector == null)
            {
                Assert.NotEqual(NoOpPersistentStorage.Instance, storage);
            }

            return(storage);
        }
        internal async Task <IChecksummedPersistentStorage> GetStorageFromKeyAsync(
            HostWorkspaceServices services, SolutionKey solutionKey, IPersistentStorageFaultInjector?faultInjector = null)
        {
            // If we handed out one for a previous test, we need to shut that down first
            _storageService?.GetTestAccessor().Shutdown();
            var configuration = new MockPersistentStorageConfiguration(solutionKey.Id, _persistentFolder.Path, throwOnFailure: true);

            _storageService = GetStorageService((IMefHostExportProvider)services.HostServices, configuration, faultInjector, _persistentFolder.Path);
            var storage = await _storageService.GetStorageAsync(solutionKey, CancellationToken.None);

            // If we're injecting faults, we expect things to be strange
            if (faultInjector == null)
            {
                Assert.NotEqual(NoOpPersistentStorage.TestAccessor.StorageInstance, storage);
            }

            return(storage);
        }