public void CanReadVariableSizedArraysInMultiValueStream()
        {
            var  ms    = new MemoryStream();
            uint count = 0;

            using (var bw = new BinaryWriter(ms, Encoding.UTF8, true))
            {
                uint len = 0;
                bw.Write((uint)0);

                for (var i = 1; i < 11; ++i)
                {
                    for (var j = 0; j < i; ++j)
                    {
                        bw.Write(i);
                        len += sizeof(int);
                        ++count;
                    }
                }

                ms.Position = 0;
                bw.Write(len);
            }

            using (var buf = new BufferedValueArray.FixedLengthBufferedValueArray <int>(ms.GetBuffer(), 0, (int)ms.Length))
            {
                var data = new Dictionary <long, uint>();
                Assert.AreEqual(count, buf.ReadValuesInto(data, 0));

                for (var i = 1; i < 11; ++i)
                {
                    Assert.AreEqual((uint)i, data[i]);
                }
            }
        }
        public void CannotCreateStreamsOfOtherTypes()
        {
            try
            {
                var b = new BufferedValueArray.FixedLengthBufferedValueArray <float>(new byte[sizeof(float)], 0, sizeof(float));
                b.ReadValuesInto(new Dictionary <long, uint>(), 0);
                Assert.Fail();
            }
            catch (TypeInitializationException e)
            {
                Assert.AreEqual(e.InnerException.GetType(), typeof(NotSupportedException));
            }

            try
            {
                var b = new BufferedValueArray.FixedLengthBufferedValueArray <string>(new byte[128], 0, 128);
                b.ReadValuesInto(new Dictionary <long, uint>(), 0);
                Assert.Fail();
            }
            catch (TypeInitializationException e)
            {
                Assert.AreEqual(e.InnerException.GetType(), typeof(NotSupportedException));
            }
        }
        public void CannotCreateStreamsOfOtherTypes()
        {
            try
            {
                var b = new BufferedValueArray.FixedLengthBufferedValueArray<float>(new byte[sizeof(float)], 0, sizeof(float));
                b.ReadValuesInto(new Dictionary<long, uint>(), 0);
                Assert.Fail();
            }
            catch (TypeInitializationException e)
            {
                Assert.AreEqual(e.InnerException.GetType(), typeof(NotSupportedException));
            }

            try
            {
                var b = new BufferedValueArray.FixedLengthBufferedValueArray<string>(new byte[128], 0, 128);
                b.ReadValuesInto(new Dictionary<long, uint>(), 0);
                Assert.Fail();
            }
            catch (TypeInitializationException e)
            {
                Assert.AreEqual(e.InnerException.GetType(), typeof(NotSupportedException));
            }
        }
        public void CanReadVariableSizedArraysInMultiValueStream()
        {
            var ms = new MemoryStream();
            uint count = 0;
            using (var bw = new BinaryWriter(ms, Encoding.UTF8, true))
            {
                uint len = 0;
                bw.Write((uint)0);

                for (var i = 1; i < 11; ++i)
                {
                    for (var j = 0; j < i; ++j)
                    {
                        bw.Write(i);
                        len += sizeof(int);
                        ++count;
                    }
                }

                ms.Position = 0;
                bw.Write(len);
            }

            using (var buf = new BufferedValueArray.FixedLengthBufferedValueArray<int>(ms.GetBuffer(), 0, (int)ms.Length))
            {
                var data = new Dictionary<long, uint>();
                Assert.AreEqual(count, buf.ReadValuesInto(data, 0));

                for (var i = 1; i < 11; ++i)
                {
                    Assert.AreEqual((uint)i, data[i]);
                }
            }
        }