示例#1
0
        public void TestGetChunk()
        {
            var data0 = RandomBytes(7101, -0x02F0B4EF);

            using (var bb = new TestByteBuffer(data0))
            {
                var dst = bb.GetChunk(1007, 4361);
                Assert.AreEqual(4361, dst.Length, "GetChunk(int,int) - length");
                Assert.AreEqual(0, bb.StreamPosition, "GetChunk(int,int) - StreamPosition");
                AssertAreEqual(data0, 1007, dst, 0, 4361, "GetChunk(int,int) - actual data");

                bb.InitializeStream(position: 42);
                dst = bb.GetChunk(1007, 4361);
                Assert.AreEqual(4361, dst.Length, "GetChunk(int,int) - length - after Stream initialized");
                Assert.AreEqual(42, bb.StreamPosition, "GetChunk(int,int) - StreamPosition - after Stream initialized");
                AssertAreEqual(data0, 1007, dst, 0, 4361, "GetChunk(int,int) - actual data after Stream initialized");
            }
        }
        public void TestGetChunk()
        {
            var data0 = RandomBytes(10000000, 0);
            var stats = TestByteBufferStatistics.Empty;

            using (var bb = new TestByteBuffer(data0))
            {
                bb.GetChunk(0, 750000);
                stats += bb.LastStatistics;

                bb.GetChunk(750000, 750000 + 1);
                stats += bb.LastStatistics;

                bb.GetChunk(1500000 + 1, 500000);
                stats += bb.LastStatistics;

                bb.GetChunk(2000000 + 1, 1000000 - 1);
                stats += bb.LastStatistics;

                bb.GetChunk(3000000, 1001101);
                stats += bb.LastStatistics;
            }

            using (var bb = new TestByteBuffer(data0))
            {
                bb.InitializeStream();
                bb.GetChunk(0, 750000);
                stats += bb.LastStatistics;

                bb.GetChunk(750000, 750000 + 1);
                stats += bb.LastStatistics;

                bb.GetChunk(1500000 + 1, 500000);
                stats += bb.LastStatistics;

                bb.GetChunk(2000000 + 1, 1000000 - 1);
                stats += bb.LastStatistics;

                bb.GetChunk(3000000, 1001101);
                stats += bb.LastStatistics;
            }

            Console.WriteLine(stats);
        }
		public void TestGetChunk()
		{
			var data0 = RandomBytes(10000000, 0);
			var stats = TestByteBufferStatistics.Empty;

			using (var bb = new TestByteBuffer(data0))
			{
				bb.GetChunk(0, 750000);
				stats += bb.LastStatistics;

				bb.GetChunk(750000, 750000 + 1);
				stats += bb.LastStatistics;

				bb.GetChunk(1500000 + 1, 500000);
				stats += bb.LastStatistics;

				bb.GetChunk(2000000 + 1, 1000000 - 1);
				stats += bb.LastStatistics;

				bb.GetChunk(3000000, 1001101);
				stats += bb.LastStatistics;
			}

			using (var bb = new TestByteBuffer(data0))
			{
				bb.InitializeStream();
				bb.GetChunk(0, 750000);
				stats += bb.LastStatistics;

				bb.GetChunk(750000, 750000 + 1);
				stats += bb.LastStatistics;

				bb.GetChunk(1500000 + 1, 500000);
				stats += bb.LastStatistics;

				bb.GetChunk(2000000 + 1, 1000000 - 1);
				stats += bb.LastStatistics;

				bb.GetChunk(3000000, 1001101);
				stats += bb.LastStatistics;
			}

			Console.WriteLine(stats);
		}