Esempio n. 1
0
        public void XmlRom_SetToValidBinThenModifyBin_RefreshCrcChanges()
        {
            IReadOnlyList <string> paths;
            var storageAccess       = XmlFormatRomTestStorageAccess.Initialize(out paths, TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var testBinToModifyPath = paths[0];

            var rom = new XmlRom();

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

            using (var binStream = storageAccess.Open(testBinToModifyPath))
            {
                binStream.Seek(0, System.IO.SeekOrigin.End);
                var dataToAppend = Enumerable.Repeat((byte)0xFF, 128).ToArray();
                binStream.Write(dataToAppend, 0, 128);
                binStream.Seek(0, System.IO.SeekOrigin.Begin);
            }

            var crcChanged = false;
            var crc        = rom.RefreshCrc(out crcChanged);

            Assert.True(crcChanged);
            Assert.NotEqual(TestRomResources.TestBinCrc, crc);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void XmlRom_CreateUninitializedRomAndRefreshCrc_CrcRemainsZeroAndUnchanged()
        {
            var rom = new XmlRom();

            var changed = true;
            var crc     = rom.RefreshCrc(out changed);

            Assert.False(changed);
            Assert.Equal(0u, crc);
        }