Example #1
0
        public void Write_MasterListSync_Throw()
        {
            using var tmp = GetFile();
            var mod = new SkyrimMod(WriteKey, SkyrimRelease.SkyrimLE);

            mod.Weapons.RecordCache.Set(
                new Weapon(FormKey.Factory("012345:Skyrim.esm"), SkyrimRelease.SkyrimLE));
            Assert.Throws <RecordException>(
                () =>
            {
                try
                {
                    mod.WriteToBinary(
                        tmp.File.Path,
                        new BinaryWriteParameters()
                    {
                        ModKey             = BinaryWriteParameters.ModKeyOption.NoCheck,
                        MastersListContent = BinaryWriteParameters.MastersListContentOption.NoCheck,
                    });
                }
                catch (RecordException ex)
                {
                    Assert.IsType <ArgumentException>(ex.InnerException);
                    throw;
                }
            });
        }
Example #2
0
 public void Dispose()
 {
     _loadOrder.Dispose();
     _outputMod.WriteToBinary(_outputPath, new BinaryWriteParameters
     {
         MasterFlag = BinaryWriteParameters.MasterFlagOption.ExceptionOnMismatch
     });
 }
Example #3
0
        public static string CreateDummyPlugin(string folder, string fileName, Action <SkyrimMod> addRecords)
        {
            Directory.CreateDirectory(folder);
            var outputPath = Path.Combine(folder, fileName);

            var mod = new SkyrimMod(ModKey.FromNameAndExtension(fileName), SkyrimRelease.SkyrimSE);

            addRecords(mod);
            mod.WriteToBinary(outputPath, Utils.SafeBinaryWriteParameters);
            return(fileName);
        }
Example #4
0
        public void BasicWrite()
        {
            using var tmp = GetFile();
            var mod  = new SkyrimMod(WriteKey, SkyrimRelease.SkyrimLE);
            var weap = mod.Weapons.AddNew();

            mod.WriteToBinary(
                tmp.File.Path,
                new BinaryWriteParameters()
            {
                ModKey             = BinaryWriteParameters.ModKeyOption.NoCheck,
                MastersListContent = BinaryWriteParameters.MastersListContentOption.NoCheck
            });
        }
Example #5
0
        public void Write_MasterListSync()
        {
            using var tmp = GetFile();
            var mod = new SkyrimMod(WriteKey, SkyrimRelease.SkyrimLE);

            mod.Weapons.RecordCache.Set(
                new Weapon(FormKey.Factory("012345:Skyrim.esm"), SkyrimRelease.SkyrimLE));
            mod.WriteToBinary(
                tmp.File.Path,
                new BinaryWriteParameters()
            {
                ModKey             = BinaryWriteParameters.ModKeyOption.NoCheck,
                MastersListContent = BinaryWriteParameters.MastersListContentOption.Iterate,
            });
        }
Example #6
0
        public static string CreateDummyPlugin(string folder, string fileName, Action <SkyrimMod> addRecords)
        {
            Directory.CreateDirectory(folder);
            var outputPath = Path.Combine(folder, fileName);

            var mod = new SkyrimMod(ModKey.FromNameAndExtension(fileName), SkyrimRelease.SkyrimSE);

            addRecords(mod);
            mod.WriteToBinary(outputPath, new BinaryWriteParameters
            {
                MasterFlag  = BinaryWriteParameters.MasterFlagOption.ExceptionOnMismatch,
                RecordCount = BinaryWriteParameters.RecordCountOption.Iterate
            });
            return(fileName);
        }
Example #7
0
        public void Write_ModNotOnLoadOrder()
        {
            using var tmp = GetFile();
            var mod = new SkyrimMod(WriteKey, SkyrimRelease.SkyrimLE);

            mod.Weapons.RecordCache.Set(
                new Weapon(FormKey.Factory("012345:Skyrim.esm"), SkyrimRelease.SkyrimLE));
            mod.Weapons.RecordCache.Set(
                new Weapon(FormKey.Factory("012345:SomeOtherMod.esp"), SkyrimRelease.SkyrimLE));
            Assert.Throws <MissingModException>(() =>
            {
                mod.WriteToBinary(
                    tmp.File,
                    new BinaryWriteParameters()
                {
                    ModKey              = BinaryWriteParameters.ModKeyOption.NoCheck,
                    MastersListContent  = BinaryWriteParameters.MastersListContentOption.Iterate,
                    MastersListOrdering = new BinaryWriteParameters.MastersListOrderingByLoadOrder(
                        Skyrim.Constants.Skyrim.AsEnumerable())
                });
            });
        }
Example #8
0
 public void Dispose()
 {
     _loadOrder.Dispose();
     _outputMod.WriteToBinary(_outputPath, Utils.SafeBinaryWriteParameters);
 }