Пример #1
0
        private void CreateTestCase_Split(int streamLength, int partLength)
        {
            var expectedPartCount = (int)Math.Ceiling((decimal)streamLength / partLength);

            using (var stream = Bio.RandomStream(streamLength)) {
                var i = 0;
                foreach (var part in stream.Split(partLength))
                {
                    i++;

                    var expected = partLength;
                    if (i == expectedPartCount)
                    {
                        var rest = streamLength % partLength;
                        if (rest > 0)
                        {
                            expected = rest;
                        }
                    }

                    Assert.AreEqual(expected, part.Length);
                }

                Assert.AreEqual(expectedPartCount, i);
            }
        }
Пример #2
0
        public void Append()
        {
            const int APPEND_LENGTH = 16;
            var       stream        = Bio.RandomStream(APPEND_LENGTH);

            concatenated.Position = stream1.Length;
            concatenated.Append(stream);

            Assert.AreEqual(combinedLength + APPEND_LENGTH, concatenated.Length);
            Assert.AreEqual(concatenated.Position, stream1.Length);
            Assert.IsTrue(stream.IsEqualTo(concatenated.ExtractFrom(combinedLength)));
        }
Пример #3
0
        public void InitializeTests()
        {
            stream1        = Bio.RandomStream(32);
            stream2        = Bio.RandomStream(16);
            combinedLength = stream1.Length + stream2.Length;

            combinedData = new byte[combinedLength];
            stream1.Read(combinedData, 0, (int)stream1.Length);
            stream2.Read(combinedData, (int)stream1.Length, (int)stream2.Length);

            stream1.MoveToStart();
            stream2.MoveToStart();

            concatenated = new ConcatenatedStream(stream1, stream2);
        }
Пример #4
0
        public void InitializeTests()
        {
            emptyStream = new MemoryStream();

            var data = new byte[STREAM_LENGTH];

            nullBytesStream = new MemoryStream(data);

            // Important: data needs to be a new object, otherwise the nullBytesStream will contain the searchNeedle.
            data = new byte[STREAM_LENGTH];

            searchStream          = new MemoryStream(data);
            searchStream.Position = STREAM_LENGTH / 2;
            searchStream.Write(searchNeedle, 0, searchNeedle.Length);
            searchStream.Position = 0;

            randomStream = Bio.RandomStream(STREAM_LENGTH);
        }
Пример #5
0
 public void InitializeTests()
 {
     baseStream   = Bio.RandomStream(BASE_LENGTH);
     offsetStream = new OffsetStream(baseStream, OFFSET);
 }