Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public async Task CompileWithMutagenCore()
        {
            var settings = new CodeSnippetPatcherSettings()
            {
                On       = true,
                Code     = $"var modPath = {nameof(ModPath)}.{nameof(ModPath.Empty)}; modPath.Equals({nameof(ModPath)}.{nameof(ModPath.Empty)});",
                Nickname = "UnitTests",
            };
            var snippet = new CodeSnippetPatcherRun(settings);
            var result  = snippet.Compile(GameRelease.SkyrimSE, CancellationToken.None, out var _);

            Assert.True(result.Success);
        }
Ejemplo n.º 4
0
 public async Task CompileWithSpecificGames()
 {
     foreach (var game in EnumExt.GetValues <GameRelease>())
     {
         var settings = new CodeSnippetPatcherSettings()
         {
             On       = true,
             Code     = $"var id = {game.ToCategory()}Mod.DefaultInitialNextFormID; id++;",
             Nickname = "UnitTests",
         };
         var snippet = new CodeSnippetPatcherRun(settings);
         var result  = snippet.Compile(game, CancellationToken.None, out var _);
         Assert.True(result.Success);
     }
 }
Ejemplo n.º 5
0
        public async Task CompileBasic()
        {
            var settings = new CodeSnippetPatcherSettings()
            {
                On       = true,
                Code     = @"// Let's do work! 
                    int wer = 23; 
                    wer++;",
                Nickname = "UnitTests",
            };
            var snippet = new CodeSnippetPatcherRun(settings);
            var result  = snippet.Compile(GameRelease.SkyrimSE, CancellationToken.None, out var _);

            Assert.True(result.Success);
        }
Ejemplo n.º 6
0
 public CodeSnippetPatcherRun(CodeSnippetPatcherSettings settings)
 {
     Name         = settings.Nickname;
     Code         = settings.Code;
     AssemblyName = $"{Name} - {System.Threading.Interlocked.Increment(ref UniquenessNumber)}";
 }