public void RebuildCacheIfNotCurrentScansAll() { _fixture.Customizations.Add(new MountPointInfoBuilder()); List <MountPointInfo> mountPoints = _fixture.CreateMany <MountPointInfo>().ToList(); List <TemplateInfo> templates = TemplatesFromMountPoints(mountPoints); SetupUserSettings(isCurrentVersion: false, mountPoints: mountPoints); SetupTemplates(templates); MockMountPointManager mockMountPointManager = new MockMountPointManager(_environmentSettings); SettingsLoader subject = new SettingsLoader(_environmentSettings, mockMountPointManager); subject.RebuildCacheFromSettingsIfNotCurrent(false); // All mount points should have been scanned AssertMountPointsWereScanned(mountPoints); }
public void RebuildCacheFromSettingsOnlyScansOutOfDateFileSystemMountPoints() { _fixture.Customizations.Add(new MountPointInfoBuilder(FileSystemMountPointFactory.FactoryId)); List <MountPointInfo> mountPoints = _fixture.Build <MountPointInfo>() .CreateMany() .ToList(); List <TemplateInfo> templates = TemplatesFromMountPoints(mountPoints); DateTime oldTimestamp = new DateTime(2018, 1, 1); DateTime recentTimestamp = new DateTime(2018, 9, 28); DateTime moreRecentTimestamp = new DateTime(2018, 9, 29); foreach (TemplateInfo templateInfo in templates) { MountPointInfo mountPoint = mountPoints.Single(mp => mp.MountPointId == templateInfo.ConfigMountPointId); // The first template has a recent timestamp in the cache, but a more // recent one on disk templateInfo.ConfigTimestampUtc = templateInfo == templates.First() ? recentTimestamp : oldTimestamp; DateTime fileTimestamp = templateInfo == templates.First() ? moreRecentTimestamp : oldTimestamp; string pathToTemplateFile = Path.Combine(mountPoint.Place, templateInfo.ConfigPlace.TrimStart('/')); _fileSystem.Add(pathToTemplateFile, "{}", lastWriteTime: fileTimestamp); } SetupUserSettings(isCurrentVersion: true, mountPoints: mountPoints); SetupTemplates(templates); MockMountPointManager mockMountPointManager = new MockMountPointManager(_environmentSettings); SettingsLoader subject = new SettingsLoader(_environmentSettings, mockMountPointManager); subject.RebuildCacheFromSettingsIfNotCurrent(false); // Only the first mount point should have been scanned AssertMountPointsWereScanned(mountPoints.Take(1)); }
public void RebuildCacheSkipsNonAccessibleMounts() { _fixture.Customizations.Add(new MountPointInfoBuilder()); List <MountPointInfo> availableMountPoints = _fixture.CreateMany <MountPointInfo>().ToList(); List <MountPointInfo> unavailableMountPoints = _fixture.CreateMany <MountPointInfo>().ToList(); List <MountPointInfo> allMountPoints = availableMountPoints.Concat(unavailableMountPoints).ToList(); List <TemplateInfo> templates = TemplatesFromMountPoints(allMountPoints); SetupUserSettings(isCurrentVersion: false, mountPoints: allMountPoints); SetupTemplates(templates); MockMountPointManager mockMountPointManager = new MockMountPointManager(_environmentSettings); mockMountPointManager.UnavailableMountPoints.AddRange(unavailableMountPoints); SettingsLoader subject = new SettingsLoader(_environmentSettings, mockMountPointManager); subject.RebuildCacheFromSettingsIfNotCurrent(false); // All mount points should have been scanned AssertMountPointsWereScanned(availableMountPoints); AssertMountPointsWereNotScanned(unavailableMountPoints); }