public void MakeSureYouCannotPutNegativeNumbersInTheBlock()
        {
            byte[]    bytes            = new byte[4096];
            const int numberOfIntegers = 10;

            var block = new IntegerListConstrained(bytes, 2, numberOfIntegers + 1);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentOutOfRangeException>(
                delegate
            {
                block[0] = -1;
            });

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentOutOfRangeException>(
                delegate
            {
                block.AddInteger(-2);
            });

            MemoryStream stream = new MemoryStream(bytes, true);
            BinaryWriter writer = new BinaryWriter(stream);

            writer.Write((int)-56);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new IntegerListConstrained(bytes, 2, numberOfIntegers + 1);
            });
        }
        public void MakeSureYouCannotAddIntegersIfTheBlockIsFull()
        {
            byte[]    bytes            = new byte[4096];
            const int numberOfIntegers = 10;

            IntegerListConstrained integersList = new IntegerListConstrained(bytes, numberOfIntegers, numberOfIntegers + 1);

            int initialCount = integersList.Count;

            Assert.AreEqual(numberOfIntegers, initialCount);

            integersList.AddInteger(1234);

            int count = integersList.Count;

            Assert.AreEqual(initialCount + 1, count);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <InvalidOperationException>(
                delegate
            {
                integersList.AddInteger(44);
            });
        }