Ejemplo n.º 1
0
        public void TestTwoParts(int bufferSize)
        {
            var input  = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 1, 2, 3, 4, 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 5, 6 };
            var first  = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 1, 2, 3, 4 };
            var second = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0, 5, 6 };

            var inputStream = MakeInputStream(input);

            try
            {
                var reader = new ArсhivePartReader(new LoggerDummy());
                reader.Init(inputStream, input.Length);
                reader.BufferSize = bufferSize;
                var firstPart = new FilePart("dummyName");
                var res       = reader.ReadPart(firstPart);

                Assert.IsTrue(res, "не удалось проинициализировать firstPart");
                Assert.IsNotNull(firstPart.Source, "firstPart.Source = null");
                Assert.IsTrue(first.SequenceEqual(firstPart.Source), "неверный firstPart.Source");
                Assert.IsFalse(firstPart.IsLast, "firstPart.IsLast");

                var secondPart = new FilePart("dummyName");
                res = reader.ReadPart(secondPart);

                Assert.IsTrue(res, "не удалось проинициализировать secondPart");
                Assert.IsNotNull(secondPart.Source, "secondPart.Source = null");
                Assert.IsTrue(second.SequenceEqual(secondPart.Source), "неверный secondPart.Source");
                Assert.IsTrue(secondPart.IsLast, "secondPart.IsLast");
            }
            finally
            {
                inputStream.Close();
            }
        }
Ejemplo n.º 2
0
        public void TestNotFirstTitle()
        {
            var input       = new byte[] { 1, 31, 139, 8, 0, 0, 0, 0, 0, 4, 0 };
            var inputStream = MakeInputStream(input);

            try
            {
                var reader = new ArсhivePartReader(new LoggerDummy());
                reader.Init(inputStream, input.Length);
                var part = new FilePart("dummyName");
                reader.ReadPart(part);
            }
            finally
            {
                inputStream.Close();
            }
        }
Ejemplo n.º 3
0
        public void TestEmptyStream()
        {
            var input       = new byte[] {};
            var inputStream = new MemoryStream();

            try
            {
                var reader = new ArсhivePartReader(new LoggerDummy());
                reader.Init(inputStream, 0);
                var part = new FilePart("dummyName");
                var res  = reader.ReadPart(part);

                Assert.IsTrue(res, "не удалось проинициализировать part из пустого потока");
                Assert.IsNotNull(part.Source, "у непроинициализированной части source должен быть Null");
                Assert.IsTrue(part.Source.SequenceEqual(input), "part.Source");
                Assert.IsTrue(part.IsLast, "part.IsLast");
            }
            finally
            {
                inputStream.Close();
            }
        }
Ejemplo n.º 4
0
        public void TestOnlyTitle(int bufferSize)
        {
            var input       = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 0 };
            var inputStream = MakeInputStream(input);

            try
            {
                var reader = new ArсhivePartReader(new LoggerDummy());
                reader.Init(inputStream, input.Length);
                reader.BufferSize = bufferSize;
                var part = new FilePart("dummyName");
                var res  = reader.ReadPart(part);

                Assert.IsTrue(res, "не удалось проинициализировать часть");
                Assert.IsNotNull(part.Source, "part.Source = null");
                Assert.IsTrue(input.SequenceEqual(part.Source), "неверный part.Source");
                Assert.IsTrue(part.IsLast, "part.IsLast");
            }
            finally
            {
                inputStream.Close();
            }
        }