Exemplo n.º 1
0
        public void EnhancedMemoryStream_String32()
        {
            var es = new EnhancedMemoryStream();

            es.WriteString32(null);
            es.WriteString32("Hello World!");
            es.WriteString32(new String('a', 45000));

            es.Seek(0, SeekOrigin.Begin);
            Assert.IsNull(es.ReadString32());
            Assert.AreEqual("Hello World!", es.ReadString32());
            Assert.AreEqual(new String('a', 45000), es.ReadString32());
        }
Exemplo n.º 2
0
        public void EnhancedMemoryStream_VerifyBufLength()
        {
            var es = new EnhancedMemoryStream();

            es.WriteInt16(5000);
            es.Seek(0, SeekOrigin.Begin);
            try
            {
                es.ReadBytes16();
                Assert.Fail();
            }
            catch
            {
            }

            es.Seek(0, SeekOrigin.Begin);
            try
            {
                es.ReadString16();
                Assert.Fail();
            }
            catch
            {
            }

            es.Seek(0, SeekOrigin.Begin);
            es.WriteInt32(500000);
            try
            {
                es.ReadBytes32();
                Assert.Fail();
            }
            catch
            {
            }

            es.Seek(0, SeekOrigin.Begin);
            try
            {
                es.ReadString32();
                Assert.Fail();
            }
            catch
            {
            }
        }