Example #1
0
        public void WriteThrowsIfWouldGoOutOfBounds()
        {
            var mem = new FixedMemory(10);
            var buf = new byte[20];

            Assert.Throws <IndexOutOfRangeException>(() => mem.Write(0, buf));
        }
Example #2
0
        public void WriteThrowsIfOffsetIsNegative()
        {
            var mem = new FixedMemory(10);
            var buf = new byte[5];
            var ex  = Assert.Throws <ArgumentOutOfRangeException>(() => mem.Write(-1, buf));

            Assert.Equal("offset", ex.ParamName);
        }
Example #3
0
        public void WriteThrowsIfReadOnly()
        {
            var mem = new FixedMemory(10, canRead: true, canWrite: false);
            var buf = new byte[5] {
                1, 2, 3, 4, 5
            };

            Assert.Throws <InvalidOperationException>(() => mem.Write(0, buf));
        }
Example #4
0
        public void WriteUpdatesData()
        {
            var mem = new FixedMemory(10);
            var buf = new byte[5] {
                1, 2, 3, 4, 5
            };

            mem.Write(2, buf.AsSpan());

            Assert.Equal(new byte[] { 0, 0, 1, 2, 3, 4, 5, 0, 0, 0 }, mem.Data.ToArray());
        }