Пример #1
0
        public void ReadThrowsIfWouldGoOutOfBounds()
        {
            var ram = CreateFixedMemory(10);
            var mem = new MirroredMemory(50, ram);
            var buf = new byte[5];

            Assert.Throws <IndexOutOfRangeException>(() => mem.Read(49, buf));
        }
Пример #2
0
        public void ReadThrowsIfOffsetIsNegative()
        {
            var mem = new MirroredMemory(10, new FixedMemory(10));
            var buf = new byte[5];
            var ex  = Assert.Throws <ArgumentOutOfRangeException>(() => mem.Read(-1, buf));

            Assert.Equal("offset", ex.ParamName);
        }
Пример #3
0
        public void ReadMirrorsAsManyTimesAsNecessaryToFillRead()
        {
            var ram = CreateFixedMemory(5);
            var mem = new MirroredMemory(15, ram);
            var buf = new byte[10];

            mem.Read(3, buf);

            Assert.Equal(
                new byte[] { 4, 5, 1, 2, 3, 4, 5, 1, 2, 3 },
                buf);
        }