public PipelineSettingsV1Upgrader( IFileSystem fileSystem, IExtraDataPathProvider extraDataPathProvider) { _fileSystem = fileSystem; _extraDataPathProvider = extraDataPathProvider; }
public PatcherExtraDataPathProvider( IPatcherNameProvider nameProvider, IProfileNameProvider profileNameProvider, IExtraDataPathProvider extraDataPathProvider) { NameProvider = nameProvider; ProfileNameProvider = profileNameProvider; ExtraDataPathProvider = extraDataPathProvider; }
public void MakesV1Backup(IExtraDataPathProvider extraDataPathProvider) { MakeImporter(extraDataPathProvider, out var mockFileSystem) .Import(V1FilePath); mockFileSystem.File.Exists(V1FilePathBackup) .Should().BeTrue(); mockFileSystem.File.ReadAllText(V1FilePath).Should().Be( mockFileSystem.File.ReadAllText(V1FilePathBackup)); }
public void Upgrade(IExtraDataPathProvider extraDataPathProvider) { var import = MakeImporter(extraDataPathProvider, out var mockFileSystem) .Import(V1FilePath); mockFileSystem.File.WriteAllText("C:/Test", JsonConvert.SerializeObject(import, Formatting.Indented, Synthesis.Bethesda.Execution.Constants.JsonSettings)); var expected = IFileSystemExt.DefaultFilesystem.File.ReadAllText("Migration/PipelineSettings.v2.json"); var reimport = mockFileSystem.File.ReadAllText("C:/Test"); reimport.Should().Be(expected); }
public void MovesUserData( IExtraDataPathProvider extraDataPathProvider) { var patcherNames = new string[] { "Patcher1", "Patcher2", "Patcher3", }; var importer = MakeImporter(extraDataPathProvider, out var mockFileSystem); mockFileSystem.Directory.CreateDirectory(extraDataPathProvider.Path); mockFileSystem.Directory.CreateDirectory(Path.Combine(extraDataPathProvider.Path, "Patcher1")); mockFileSystem.File.WriteAllText(Path.Combine(extraDataPathProvider.Path, "Patcher1", "settings.json"), string.Empty); mockFileSystem.Directory.CreateDirectory(Path.Combine(extraDataPathProvider.Path, "Patcher2")); mockFileSystem.File.WriteAllText(Path.Combine(extraDataPathProvider.Path, "Patcher2", "settings.json"), string.Empty); mockFileSystem.Directory.CreateDirectory(Path.Combine(extraDataPathProvider.Path, "Patcher3")); mockFileSystem.File.WriteAllText(Path.Combine(extraDataPathProvider.Path, "Patcher3", "settings.json"), string.Empty); mockFileSystem.Directory.CreateDirectory(Path.Combine(extraDataPathProvider.Path, "Patcher4")); mockFileSystem.File.WriteAllText(Path.Combine(extraDataPathProvider.Path, "Patcher4", "settings.json"), string.Empty); importer.Import(V1FilePath); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Patcher1")) .Should().BeFalse(); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Patcher2")) .Should().BeFalse(); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Patcher3")) .Should().BeFalse(); foreach (var name in patcherNames) { mockFileSystem.File.Exists(Path.Combine(extraDataPathProvider.Path, name)) .Should().BeFalse(); } mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Profile1", "Patcher1")) .Should().BeTrue(); mockFileSystem.File.Exists(Path.Combine(extraDataPathProvider.Path, "Profile1", "Patcher1", "settings.json")) .Should().BeTrue(); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Profile1", "Patcher2")) .Should().BeTrue(); mockFileSystem.File.Exists(Path.Combine(extraDataPathProvider.Path, "Profile1", "Patcher2", "settings.json")) .Should().BeTrue(); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Profile2", "Patcher3")) .Should().BeTrue(); mockFileSystem.File.Exists(Path.Combine(extraDataPathProvider.Path, "Profile2", "Patcher3", "settings.json")) .Should().BeTrue(); mockFileSystem.Directory.Exists(Path.Combine(extraDataPathProvider.Path, "Unknown Profile", "Patcher4")) .Should().BeTrue(); mockFileSystem.File.Exists(Path.Combine(extraDataPathProvider.Path, "Unknown Profile", "Patcher4", "settings.json")) .Should().BeTrue(); }
public PipelineSettingsImporter MakeImporter( IExtraDataPathProvider extraDataPathProvider, out MockFileSystem fileSystem) { fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>() { { V1FilePath, File.ReadAllText("Migration/PipelineSettings.json") } }); return(new PipelineSettingsImporter( new PipelineSettingsV1Reader(fileSystem), new PipelineSettingsV2Reader(fileSystem), new PipelineSettingsUpgrader( new PipelineSettingsV1Upgrader( fileSystem, extraDataPathProvider)), new PipelineSettingsBackup(fileSystem), new PipelineSettingsVersionRetriever(fileSystem))); }