public async Task CreatesOutput() { using var tmpFolder = Utility.GetTempFolder(); using var dataFolder = Utility.SetupDataFolder(tmpFolder, GameRelease.Oblivion); var settings = new CodeSnippetPatcherSettings() { On = true, Code = @"// Let's do work! int wer = 23; wer++;", Nickname = "UnitTests", }; var outputFile = Utility.TypicalOutputFile(tmpFolder); var snippet = new CodeSnippetPatcherRun(settings); await snippet.Prep(GameRelease.Oblivion, CancellationToken.None); await snippet.Run(new RunSynthesisPatcher() { OutputPath = ModPath.FromPath(outputFile), DataFolderPath = dataFolder.Dir.Path, GameRelease = GameRelease.Oblivion, LoadOrderFilePath = Utility.PathToLoadOrderFile, SourcePath = null }, CancellationToken.None); Assert.True(File.Exists(outputFile)); }
public async Task RunTwice() { using var tmpFolder = Utility.GetTempFolder(); using var dataFolder = Utility.SetupDataFolder(tmpFolder, GameRelease.Oblivion); var outputFile = Utility.TypicalOutputFile(tmpFolder); var settings = new CodeSnippetPatcherSettings() { On = true, Code = @"state.PatchMod.Npcs.AddNew();", Nickname = "UnitTests", }; for (int i = 0; i < 2; i++) { var snippet = new CodeSnippetPatcherRun(settings); await snippet.Prep(GameRelease.Oblivion, CancellationToken.None); await snippet.Run(new RunSynthesisPatcher() { OutputPath = ModPath.FromPath(outputFile), DataFolderPath = dataFolder.Dir.Path, GameRelease = GameRelease.Oblivion, LoadOrderFilePath = Utility.PathToLoadOrderFile, SourcePath = i == 1 ? outputFile.Path : null }, CancellationToken.None); } using var mod = OblivionMod.CreateFromBinaryOverlay(outputFile); Assert.Equal(2, mod.Npcs.Count); }