Beispiel #1
0
        public void TestCopyFromStream_Small()
        {
            NcByteCollection b1 = new NcByteCollection(NcTestUtils.RandomBytes(30 * 1000));
            NcByteStream     b2 = new NcByteStream(NcTestUtils.RandomBytes(1000));

            b1.Copy(b2, 5000, 50);
            Assert.IsTrue(b1.Count == (30 * 1000));
            Assert.IsTrue(b1.SequenceEqual(b1.Take(5000).Concat(b2.Data.Take(50)).Concat(b1.Skip(5050))));
        }
Beispiel #2
0
        public void TestCopyFromArray_Small()
        {
            NcByteCollection b1 = new NcByteCollection(NcTestUtils.RandomBytes(30 * 1000));

            byte[] b2 = NcTestUtils.RandomBytes(1000);

            b1.Copy(b2, 0, 5000, 50);
            Assert.IsTrue(b1.Count == (30 * 1000));
            Assert.IsTrue(b1.SequenceEqual(b1.Take(5000).Concat(b2.Take(50)).Concat(b1.Skip(5050))));
        }
Beispiel #3
0
        public void TestStreamWrite()
        {
            NcByteCollection original = new NcByteCollection(NcTestUtils.RandomBytes(12 * 1024));
            NcByteStream     stream   = new NcByteStream(original);
            MemoryStream     ms       = new MemoryStream(NcTestUtils.RandomBytes(5 * 1024));

            stream.Seek(5 * 1024, SeekOrigin.Begin);
            ms.CopyTo(stream);

            Assert.IsTrue(original.Take(5 * 1024).Concat(ms.ToArray()).Concat(original.Skip(5 * 1024 + 5 * 1024)).SequenceEqual(stream.Data));
        }