Exemple #1
0
        public void ManagedStream()
        {
            managedStream.ResetWrite(m_byteBuf);

            for (int i = 0; i < AMOUNT; i++)
            {
                managedStream.Write(i);
            }
        }
Exemple #2
0
        public void ResetWriteDefault()
        {
            ManagedStream bs = new ManagedStream();

            bs.ResetWrite();

            Assert.AreEqual(SerializationMode.Writing, bs.Mode);
            Assert.IsTrue(bs.IsWriting);

            Assert.AreEqual(ManagedStream.DefaultBufferSize, bs.Length);
        }
Exemple #3
0
        public void ExpandStreamTest()
        {
            ManagedStream ms = new ManagedStream();

            ms.ResetWrite(2);

            ms.Write(123);

            // Resizes to the next power of two.
            // Which is 2 -> 4
            Assert.AreEqual(4, ms.Length);
        }
Exemple #4
0
        public void InvalidateStream()
        {
            ManagedStream bs = new ManagedStream();

            bs.ResetWrite(new byte[2], true);

            Assert.Catch <InvalidOperationException>(() =>
            {
                bs.Write <int>(321);
            });

            Assert.AreEqual(2, bs.Length);
        }
Exemple #5
0
        public void InvalidateStreamer()
        {
            ManagedStream bs = new ManagedStream();

            bs.ResetWrite(new byte[4], true);

            bs.Write <int>(123);

            Assert.Catch <InvalidOperationException>(() =>
            {
                bs.Write <int>(321);
            });
        }
Exemple #6
0
        public void ReadWriteTest()
        {
            bs.ResetWrite(m_buffer);

            bs.Write(123);

            bs.ResetRead();

            int res = 0;

            bs.Read(ref res);
            Assert.AreEqual(123, res);
        }
Exemple #7
0
        public void ResetStreamer()
        {
            ManagedStream bs = new ManagedStream();

            bs.ResetWrite(new byte[8], true);

            bs.Write <int>(333);

            Assert.AreEqual(4, bs.Offset);
            Assert.IsTrue(bs.IsWriting);

            bs.ResetRead();

            Assert.AreEqual(0, bs.Offset);
            Assert.IsTrue(bs.IsReading);
        }
Exemple #8
0
        public void LargeStringWrite()
        {
            ManagedStream ms = new ManagedStream();

            ms.ResetWrite(2);

            StringBuilder sb = new StringBuilder(50);

            for (int i = 0; i < 50; i++)
            {
                sb.Append(i);
            }

            var str = sb.ToString();

            ms.WriteString(str, Encoding.Default);

            Assert.IsTrue(ms.Length >= 64);

            ms.ResetRead();

            Assert.AreEqual(str, ms.ReadString(Encoding.Default));
        }