public void SaveAndLoadTest() { string filename = "test.hex"; byte[] newdata = new byte[1025]; BinaryBlock bb = new BinaryBlock(0x00010000 - 500); BinaryBlock bb1 = new BinaryBlock(0x00010000 - 50); bb.Append(newdata); bb1.Append(newdata); IntelHexFile.SaveAsIntelHex(filename, new BinaryBlock[] { bb, bb1 }); IntelHexFile hf = new IntelHexFile(); hf.Load(filename); Assert.AreEqual(2, hf.Blocks.Count); // Check binary black Assert.AreEqual(bb.Address, hf.Blocks[0].Address); Assert.AreEqual(bb.Length, hf.Blocks[0].Length); bb.UpdateHash(eHash.CRC32); Assert.AreEqual(bb.DisplayHash, hf.Blocks[0].DisplayHash); bb.UpdateHash(eHash.SHA256); Assert.AreNotEqual(bb.DisplayHash, hf.Blocks[0].DisplayHash); hf.UpdateHash(eHash.SHA256); Assert.AreEqual(bb.DisplayHash, hf.Blocks[0].DisplayHash); // append the same file again hf.Load(filename, eHash.CRC32, true); Assert.AreEqual(4, hf.Blocks.Count); }
private void hashType_SelectedIndexChanged(object sender, EventArgs e) { hexf.UpdateHash((eHash)comboBox.SelectedItem); }