コード例 #1
0
        public void XmlRom_SetToValidBinPathChangeCfgPath_BinCrcUnchangedAndCfgCrcUpdatesImmediately()
        {
            var paths = XmlFormatRomTestStorageAccess.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath, TestRomResources.TestCfgMetadataPath);
            var rom   = new XmlRom();

            rom.UpdateRomPath(paths[0]);
            rom.UpdateConfigPath(paths[1]);
            Assert.True(rom.IsValid);
            Assert.NotNull(rom.ResolvedRom);
            Assert.Equal(RomFormat.Bin, rom.Format);
            Assert.Equal(paths[0], rom.RomPath);
            Assert.Equal(paths[1], rom.ConfigPath);
            Assert.Equal(TestRomResources.TestBinCrc, rom.Crc);
            Assert.Equal(TestRomResources.TestCfgCrc, rom.CfgCrc);

            rom.UpdateConfigPath(paths[2]);
            var crcChanged    = true;
            var crc           = rom.RefreshCrc(out crcChanged);
            var cfgCrcChanged = true;
            var cfgCrc        = rom.RefreshCfgCrc(out cfgCrcChanged);

            Assert.False(crcChanged);
            Assert.Equal(TestRomResources.TestBinCrc, rom.Crc);
            Assert.Equal(TestRomResources.TestBinCrc, crc);
            Assert.False(cfgCrcChanged);
            Assert.Equal(TestRomResources.TestMetadataCfgCrc, cfgCrc);
            Assert.Equal(TestRomResources.TestMetadataCfgCrc, rom.CfgCrc);
        }
コード例 #2
0
        public void XmlRom_CreateUninitializedRomAndRefreshCfgCrc_CfgCrcRemainsZeroAndUnchanged()
        {
            var rom = new XmlRom();

            var changed = true;
            var cfgCrc  = rom.RefreshCfgCrc(out changed);

            Assert.False(changed);
            Assert.Equal(0u, cfgCrc);
        }
コード例 #3
0
        public void XmlRom_SetToValidBinThenModifyCfg_RefreshCfgCrcChanges()
        {
            IReadOnlyList <string> paths;
            var storageAccess       = XmlFormatRomTestStorageAccess.Initialize(out paths, TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var testCfgToModifyPath = paths[1];

            var rom = new XmlRom();

            rom.UpdateRomPath(paths[0]);
            rom.UpdateConfigPath(testCfgToModifyPath);
            Assert.True(rom.IsValid);
            Assert.NotNull(rom.ResolvedRom);
            Assert.Equal(RomFormat.Bin, rom.Format);
            Assert.Equal(paths[0], rom.RomPath);
            Assert.Equal(testCfgToModifyPath, rom.ConfigPath);
            Assert.Equal(TestRomResources.TestBinCrc, rom.Crc);
            Assert.Equal(TestRomResources.TestCfgCrc, rom.CfgCrc);

            using (var cfgStream = storageAccess.Open(testCfgToModifyPath))
            {
                cfgStream.Seek(0, System.IO.SeekOrigin.End);
                var cfgToAppend =
                    @"
[vars]
name = ""wut?""
";
                var cfgDataToAppend = System.Text.Encoding.UTF8.GetBytes(cfgToAppend);
                cfgStream.Write(cfgDataToAppend, 0, cfgDataToAppend.Length);
                cfgStream.Seek(0, System.IO.SeekOrigin.Begin);
            }

            var cfgCrcChanged = false;
            var cfgCrc        = rom.RefreshCfgCrc(out cfgCrcChanged);

            Assert.True(cfgCrcChanged);
            Assert.NotEqual(TestRomResources.TestCfgCrc, cfgCrc);
            Assert.Equal("wut?", rom.GetBinFileMetadata().LongNames.First());
        }