Пример #1
0
        public void TestTwoTitles()
        {
            var input          = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 1, 31, 139, 8, 0, 0, 0, 0, 0, 4, 0 };
            var buffer         = new BytesBuffer(input, 0, input.Length - 1);
            var portion        = new ArhivePortion(buffer);
            var firstExtracted = portion.ExtractFirstTitleAndData();

            Assert.IsNotNull(firstExtracted, "firstExtracted == null");
            Assert.AreEqual(0, firstExtracted.StartPosition, "firstExtracted.StartPosition");
            Assert.AreEqual(10, firstExtracted.EndPosition, "firstExtracted.EndPosition");
            Assert.AreEqual(11, firstExtracted.Size, "firstExtracted.Size");

            Assert.IsFalse(portion.IsEmpty, "portion.IsEmpty");
            Assert.IsTrue(portion.IsExistsTitle, "portion.IsExistsTitle");

            var secondExtracted = portion.ExtractFirstTitleAndData();

            Assert.IsNotNull(secondExtracted, "secondExtracted == null");
            Assert.AreEqual(11, secondExtracted.StartPosition, "secondExtracted.StartPosition");
            Assert.AreEqual(20, secondExtracted.EndPosition, "secondExtracted.EndPosition");
            Assert.AreEqual(10, secondExtracted.Size, "secondExtracted.Size");

            Assert.IsTrue(portion.IsEmpty, "portion.IsEmpty");
            Assert.IsFalse(portion.IsExistsTitle, "portion.IsExistsTitle");
        }
Пример #2
0
        public void TestAppendPartTitle()
        {
            var first       = new byte[] { 31, 139, 8, 0, 0 };
            var firstBuffer = new BytesBuffer(first, 0, first.Length - 1);
            var portion     = new ArhivePortion(firstBuffer);

            var second       = new byte[] { 0, 0, 0, 4, 0, 1 };
            var secondBuffer = new BytesBuffer(second, 0, second.Length - 1);

            portion.Append(secondBuffer);

            Assert.IsTrue(portion.IsExistsAllTitle, "порция должна содержать title");
            var titleAndData = portion.ExtractFirstTitleAndData();

            Assert.AreEqual(0, titleAndData.StartPosition, "titleAndData.StartPosition");
            Assert.AreEqual(11, titleAndData.Size, "titleAndData.StartPosition");
            Assert.IsTrue(titleAndData.InnerBuffer.SequenceEqual(new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 1 }),
                          "неверный titleAndData");
        }