コード例 #1
0
        public void MergeWorksAsExpected()
        {
            // --- Arrange
            var dc = new DisassemblyAnnotation();

            dc.SetLabel(0x0100, "FirstLabel");
            dc.SetLabel(0x0200, "SecondLabel");
            dc.SetComment(0x0100, "FirstComment");
            dc.SetComment(0x0200, "SecondComment");
            dc.SetPrefixComment(0x0100, "FirstPrefixComment");
            dc.SetPrefixComment(0x0200, "SecondPrefixComment");
            dc.AddLiteral(0x0000, "Entry");
            dc.AddLiteral(0x0000, "Start");
            dc.AddLiteral(0x0028, "Calculator");
            dc.MemoryMap.Add(new MemorySection(0x0000, 0x3BFF));
            dc.MemoryMap.Add(new MemorySection(0x3C00, 0x3FFF, MemorySectionType.ByteArray));
            dc.SetLiteralReplacement(0x100, "Entry");
            dc.SetLiteralReplacement(0x1000, "Calculator");

            // --- Act
            var odc = new DisassemblyAnnotation();

            odc.SetLabel(0x0200, "SecondLabelA");
            odc.SetLabel(0x0300, "ThirdLabel");
            odc.SetComment(0x0100, "FirstCommentA");
            odc.SetComment(0x0300, "ThirdComment");
            odc.SetPrefixComment(0x0200, "SecondPrefixCommentA");
            odc.SetPrefixComment(0x0300, "ThirdPrefixComment");
            odc.AddLiteral(0x0000, "Start");
            odc.AddLiteral(0x0028, "CalculatorA");
            odc.MemoryMap.Add(new MemorySection(0x3C00, 0x5BFF, MemorySectionType.ByteArray));
            odc.SetLiteralReplacement(0x100, "Entry");
            odc.SetLiteralReplacement(0x200, "Other");
            odc.SetLiteralReplacement(0x1000, "CalculatorA");
            dc.Merge(odc);

            // --- Assert
            dc.Labels.Count.ShouldBe(3);
            dc.Labels[0x100].ShouldBe("FirstLabel");
            dc.Labels[0x200].ShouldBe("SecondLabelA");
            dc.Labels[0x300].ShouldBe("ThirdLabel");
            dc.Comments.Count.ShouldBe(3);
            dc.Comments[0x100].ShouldBe("FirstCommentA");
            dc.Comments[0x200].ShouldBe("SecondComment");
            dc.Comments[0x300].ShouldBe("ThirdComment");
            dc.PrefixComments.Count.ShouldBe(3);
            dc.PrefixComments[0x100].ShouldBe("FirstPrefixComment");
            dc.PrefixComments[0x200].ShouldBe("SecondPrefixCommentA");
            dc.PrefixComments[0x300].ShouldBe("ThirdPrefixComment");
            dc.Literals.Count.ShouldBe(2);
            dc.Literals[0x0000].Count.ShouldBe(2);
            dc.Literals[0x0000].ShouldContain("Start");
            dc.Literals[0x0000].ShouldContain("Entry");
            dc.Literals[0x0028].Count.ShouldBe(2);
            dc.Literals[0x0028].ShouldContain("Calculator");
            dc.Literals[0x0028].ShouldContain("CalculatorA");
            dc.MemoryMap.Count.ShouldBe(2);
            dc.MemoryMap[0].ShouldBe(new MemorySection(0x0000, 0x3BFF));
            dc.MemoryMap[1].ShouldBe(new MemorySection(0x3C00, 0x5BFF, MemorySectionType.ByteArray));
            dc.LiteralReplacements.Count.ShouldBe(3);
            dc.LiteralReplacements[0x100].ShouldBe("Entry");
            dc.LiteralReplacements[0x200].ShouldBe("Other");
            dc.LiteralReplacements[0x1000].ShouldBe("CalculatorA");
        }