public void ICloneableCloneTest()
        {
            // Just test a subset of the options
            options.MinBufferSize         = 5;
            options.MaxBufferSize         = 10;
            options.MaxBuffersPerSizeBand = 15;

            ICloneable cloneable = options;

            CachingBufferManager.Options clone = (CachingBufferManager.Options)cloneable.Clone();

            Assert.AreEqual(5, clone.MinBufferSize);
            Assert.AreEqual(10, clone.MaxBufferSize);
            Assert.AreEqual(15, clone.MaxBuffersPerSizeBand);
        }
Example #2
0
        public void CopyWithIBuffer()
        {
            CachingBufferManager.Options options = new CachingBufferManager.Options();
            options.MinBufferSize = 7;
            CachingBufferManager manager = new CachingBufferManager(options);

            StreamStub input = new StreamStub();
            input.AddReadData(new byte[] { 1, 2, 3, 4, 5 });
            input.AddReadData(new byte[] { 6, 7, 8, 9, 10 });
            MemoryStream output = new MemoryStream();
            using (IBuffer buffer = manager.GetBuffer(10))
            {
                StreamUtil.Copy(input, output, buffer);
            }
            Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, output.ToArray());
            Assert.AreEqual(14, input.LastReadSize);
        }
Example #3
0
        public void ReadFullyWithIBuffer()
        {
            CachingBufferManager.Options options = new CachingBufferManager.Options();
            options.MinBufferSize = 7;
            CachingBufferManager manager = new CachingBufferManager(options);

            StreamStub input = new StreamStub();

            input.AddReadData(new byte[] { 1, 2, 3, 4, 5 });
            input.AddReadData(new byte[] { 6, 7, 8, 9, 10 });
            byte[] actual;
            using (IBuffer buffer = manager.GetBuffer(10))
            {
                actual = StreamUtil.ReadFully(input, buffer);
            }
            Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, actual);
            Assert.AreEqual(14, input.LastReadSize);
        }
Example #4
0
        public void CopyWithIBuffer()
        {
            CachingBufferManager.Options options = new CachingBufferManager.Options();
            options.MinBufferSize = 7;
            CachingBufferManager manager = new CachingBufferManager(options);

            StreamStub input = new StreamStub();

            input.AddReadData(new byte[] { 1, 2, 3, 4, 5 });
            input.AddReadData(new byte[] { 6, 7, 8, 9, 10 });
            MemoryStream output = new MemoryStream();

            using (IBuffer buffer = manager.GetBuffer(10))
            {
                StreamUtil.Copy(input, output, buffer);
            }
            Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, output.ToArray());
            Assert.AreEqual(14, input.LastReadSize);
        }
Example #5
0
 public void SetUp()
 {
     options = new CachingBufferManager.Options();
     subject = null;
 }
Example #6
0
        public void ReadFullyWithIBuffer()
        {
            CachingBufferManager.Options options = new CachingBufferManager.Options();
            options.MinBufferSize = 7;
            CachingBufferManager manager = new CachingBufferManager(options);

            StreamStub input = new StreamStub();
            input.AddReadData(new byte[] { 1, 2, 3, 4, 5 });
            input.AddReadData(new byte[] { 6, 7, 8, 9, 10 });
            byte[] actual;
            using (IBuffer buffer = manager.GetBuffer(10))
            {
                actual = StreamUtil.ReadFully(input, buffer);
            }
            Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, actual);
            Assert.AreEqual(14, input.LastReadSize);
        }
 public void SetUp()
 {
     options = new CachingBufferManager.Options();
     subject = null;
 }