Пример #1
0
        public void GetLastBytesFromBigMemory()
        {
            ByteMemory bytememory = new ByteMemory(1000);
            byte[] bytes = bytememory.GetBytes(900, 100);

            Assert.IsNotNull(bytes);
            Assert.AreEqual(100, bytes.Length);
            Assert.IsTrue(bytes.All(b => b == 0));
        }
Пример #2
0
 public void RaiseWhenRangeIsCrossingBoundary()
 {
     ByteMemory bytememory = new ByteMemory();
     bytememory.GetBytes(90, 20);
 }
Пример #3
0
 public void RaiseWhenAddressIsNegative()
 {
     ByteMemory bytememory = new ByteMemory();
     bytememory.GetBytes(-20, 10);
 }
Пример #4
0
 public void RaiseWhenAddressIsBeyondLimits()
 {
     ByteMemory bytememory = new ByteMemory();
     bytememory.GetBytes(200, 10);
 }
Пример #5
0
        public void SetBitsToZero()
        {
            ByteMemory memory = new ByteMemory();

            memory.SetBytes(0, new byte[] { 0xff, 0xff });

            memory.SetBit(0, false);
            Assert.AreEqual(0xfe, memory.GetBytes(0, 1)[0]);
            memory.SetBit(1, false);
            Assert.AreEqual(0xfc, memory.GetBytes(0, 1)[0]);
            memory.SetBit(7, false);
            Assert.AreEqual(0x7c, memory.GetBytes(0, 1)[0]);
            memory.SetBit(8, false);
            Assert.AreEqual(0xfe, memory.GetBytes(1, 1)[0]);
            memory.SetBit(9, false);
            Assert.AreEqual(0xfc, memory.GetBytes(1, 1)[0]);
        }
Пример #6
0
        public void SetBitsToOne()
        {
            ByteMemory memory = new ByteMemory();

            memory.SetBit(0, true);
            Assert.AreEqual(0x01, memory.GetBytes(0, 1)[0]);
            memory.SetBit(1, true);
            Assert.AreEqual(0x03, memory.GetBytes(0, 1)[0]);
            memory.SetBit(7, true);
            Assert.AreEqual(0x83, memory.GetBytes(0, 1)[0]);
            memory.SetBit(8, true);
            Assert.AreEqual(0x01, memory.GetBytes(1, 1)[0]);
            memory.SetBit(9, true);
            Assert.AreEqual(0x03, memory.GetBytes(1, 1)[0]);
        }
Пример #7
0
        public void SetAndGetOneHundredBytes()
        {
            byte[] values = new byte[100];

            for (int k = 0; k < values.Length; k++)
                values[k] = (byte) k;

            ByteMemory bytememory = new ByteMemory(1000);
            bytememory.SetBytes(10, values);

            byte[] result = bytememory.GetBytes(10, values.Length);

            Assert.IsNotNull(result);
            Assert.AreEqual(100, result.Length);

            for (int k = 0; k < values.Length; k++)
                Assert.AreEqual(values[k], result[k]);
        }
Пример #8
0
        public void SetAndGetOneByte()
        {
            ByteMemory bytememory = new ByteMemory();
            bytememory.SetBytes(10, new byte[] { (byte) 16 });

            byte[] result = bytememory.GetBytes(10, 1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(16, result[0]);
        }