示例#1
0
        public void GetMemoryCrossPage2Bytes()
        {
            var mb = new Mock <IMemoryBank>();

            mb.SetupGet(b => b.HI_ADDRESS).Returns(0xFFFF);
            mb.SetupGet(b => b.LOW_ADDRESS).Returns(0xFFF0);
            var mb2 = new Mock <IMemoryBank>();

            mb2.SetupGet(b => b.HI_ADDRESS).Returns(0xFFEF);
            mb2.SetupGet(b => b.LOW_ADDRESS).Returns(0xFFE0);

            mb.Setup(b => b.GetContents(0xFFF0, 1)).Returns(new byte[] { 3 }).Verifiable("Didn't get two from second bank");
            mb2.Setup(b => b.GetContents(0xFFEF, 2)).Returns(new byte[] { 2 }).Verifiable("Didn't get four from first bank");

            IMemoryBank[] mbs = new IMemoryBank[]
            {
                mb.Object, mb2.Object
            };

            var memory = new RC2014.EMU.Memory(mbs);

            var bytes = memory.GetContents(0xFFEF, 2);

            mb.VerifyAll();
            mb2.VerifyAll();

            Assert.That(bytes, Has.Length.EqualTo(2));
            Assert.AreEqual(new byte[] { 2, 3 }, bytes);
        }
示例#2
0
        public void GetMemoryTopMostByte()
        {
            var mb = new Mock <IMemoryBank>();

            mb.SetupGet(b => b.HI_ADDRESS).Returns(0xFFFF);
            mb.SetupGet(b => b.LOW_ADDRESS).Returns(0xFFF0);

            mb.Setup(b => b.GetContents(0xFFFF, 1)).Returns(new byte[] { 9 }).Verifiable("Didn't get two from second bank");

            IMemoryBank[] mbs = new IMemoryBank[]
            {
                mb.Object
            };

            var memory = new RC2014.EMU.Memory(mbs);

            var bytes = memory.GetContents(0xFFFF, 1);

            mb.VerifyAll();

            Assert.That(bytes, Has.Length.EqualTo(1));
            Assert.AreEqual(new byte[] { 9 }, bytes);
        }