public void TestFromBytes()
        {
            var data0 = RandomBytes(10000000, 0);
            var data1 = RandomBytes(10000000, 1);
            var stats = TestByteBufferStatistics.Empty;

            using (var bb = new TestByteBuffer(data0))
            {
                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;
            }

            using (var bb = new TestByteBuffer(data0))
            {
                bb.InitializeStream();
                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;

                bb.FromBytes(data1);
                stats += bb.LastStatistics;
            }

            Console.WriteLine(stats);
        }
Ejemplo n.º 2
0
        public void TestFromBytes()
        {
            var data0 = RandomBytes(7101, -0x02F0B4EF);
            var data1 = RandomBytes(9431, -0x7BFC1702);

            using (var bb = new TestByteBuffer(data0))
            {
                bb.FromBytes(data1);

                Assert.AreEqual(9431, bb.Length, "FromBytes - length");
                Assert.AreEqual(0, bb.StreamPosition, "FromBytes - StreamPosition");
                AssertAreEqual(data1, bb.DumpTestData(), "FromBytes");
            }

            using (var bb = new TestByteBuffer(data0))
            {
                bb.InitializeStream(position: 42);
                bb.FromBytes(data1);

                Assert.AreEqual(9431, bb.Length, "FromBytes - length - after Stream initialized");
                Assert.AreEqual(0, bb.StreamPosition, "FromBytes - StreamPosition - after Stream initialized");
                AssertAreEqual(data1, bb.DumpTestData(), "FromBytes - after Stream initialized");
            }
        }
		public void TestFromBytes()
		{
			var data0 = RandomBytes(10000000, 0);
			var data1 = RandomBytes(10000000, 1);
			var stats = TestByteBufferStatistics.Empty;

			using (var bb = new TestByteBuffer(data0))
			{
				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;
			}

			using (var bb = new TestByteBuffer(data0))
			{
				bb.InitializeStream();
				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;

				bb.FromBytes(data1);
				stats += bb.LastStatistics;
			}

			Console.WriteLine(stats);
		}