internal IChecksummedPersistentStorage GetStorageFromKey(
            Workspace workspace, SolutionKey solutionKey, IPersistentStorageFaultInjector faultInjectorOpt = 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(locationService, faultInjectorOpt);
            var storage = _storageService.GetStorage(workspace, solutionKey, checkBranchId: true);

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

            return(storage);
        }
Exemple #2
0
        internal IChecksummedPersistentStorage GetStorage(
            Solution solution, IPersistentStorageFaultInjector faultInjectorOpt = null)
        {
            // For the sake of tests, all solutions are bigger than our threshold, and thus deserve to get storage for them
            var solutionSizeTrackerMock = new Mock <ISolutionSizeTracker>();

            solutionSizeTrackerMock.Setup(m => m.GetSolutionSize(solution.Workspace, solution.Id))
            .Returns(solution.Workspace.Options.GetOption(StorageOptions.SolutionSizeThreshold) + 1);

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

            _storageService = GetStorageService(locationService, solutionSizeTrackerMock.Object, faultInjectorOpt);
            var storage = _storageService.GetStorage(solution, checkBranchId: true);

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

            return(storage);
        }
Exemple #3
0
 public TestAccessor(AbstractPersistentStorageService service)
 => _service = service;