Exemple #1
0
        public void CompressFileLittleEndian()
        {
            byte[] expected =
            {
                0x00, 0x02, 0x00, 0x00, 0x31, 0x01, 0x00, 0x00, 0x78, 0xDA, 0x4D, 0x91, 0xCB, 0x6D, 0xC4, 0x30,
                0x0C, 0x44, 0x5B, 0x99, 0x02, 0x8C, 0xED, 0x21, 0xF7, 0x24, 0xC8, 0x25, 0x05, 0xD0, 0x32, 0xE3,
                0x25, 0x40, 0x49, 0x0E, 0x3F, 0x8B, 0x94, 0x1F, 0x7A, 0xF3, 0xBD, 0x48, 0x10, 0x35, 0x22, 0xE7,
                0x8D, 0x1E, 0xA7, 0x71, 0x87, 0x1C, 0x9E, 0x1D, 0xDB, 0xD4, 0x69, 0x70, 0x09, 0x50, 0xE7, 0x58,
                0xD0, 0xE6, 0x70, 0x6E, 0xC1, 0x91, 0x06, 0xDA, 0xE4, 0x10, 0x6F, 0x32, 0x76, 0xB0, 0x4A, 0x5C,
                0xF0, 0x34, 0x6D, 0x15, 0x1C, 0x57, 0x32, 0x0E, 0x23, 0x64, 0xE0, 0x76, 0x5E, 0x80, 0x77, 0x0E,
                0x1C, 0xD3, 0x82, 0x2E, 0x78, 0x0D, 0xA4, 0x2A, 0xF5, 0x36, 0xED, 0x60, 0x5B, 0x30, 0x64, 0xBD,
                0x82, 0x20, 0xBD, 0x4E, 0x9B, 0x94, 0x4E, 0xA8, 0xA5, 0x8A, 0x2F, 0xE8, 0xB4, 0x0F, 0x82, 0x89,
                0xA7, 0xA3, 0xA5, 0x9D, 0xDB, 0xE0, 0xF7, 0xE4, 0x05, 0xA5, 0x72, 0xDA, 0x25, 0x42, 0xBC, 0x54,
                0xEE, 0x54, 0xC7, 0x43, 0x78, 0x80, 0x5A, 0xF5, 0x73, 0xF9, 0x71, 0xF2, 0x63, 0x1B, 0xEC, 0x7F,
                0x2F, 0x96, 0x2F, 0x27, 0x88, 0x5A, 0x4F, 0x34, 0xDE, 0x16, 0xF8, 0x54, 0x95, 0x26, 0x91, 0x9B,
                0x0C, 0xBC, 0x95, 0x67, 0xBF, 0xE0, 0x99, 0x7A, 0xD9, 0xF7, 0x90, 0x35, 0xB5, 0x82, 0x50, 0xD9,
                0x53, 0x09, 0x54, 0x8D, 0xF8, 0xF4, 0x8A, 0x9B, 0xDC, 0xD8, 0xAC, 0x88, 0x5E, 0xAE, 0xE4, 0xAC,
                0x7A, 0xB7, 0xD7, 0xA0, 0x54, 0xE9, 0x9D, 0xB8, 0x69, 0x59, 0x5D, 0x9E, 0x88, 0x1B, 0x0F, 0xF2,
                0x33, 0x89, 0xAF, 0x1A, 0x64, 0x44, 0xA1, 0x66, 0x5F, 0xB0, 0x2A, 0x8D, 0xAD, 0x3C, 0xAA, 0xAC,
                0x6C, 0xB3, 0x2E, 0x16, 0xEC, 0x46, 0x37, 0xD9, 0x6A, 0x4E, 0xEE, 0xC9, 0xD5, 0xDB, 0x66, 0x39,
                0x62, 0xE5, 0xCE, 0x23, 0xCE, 0xEF, 0x48, 0x81, 0x6C, 0xDF, 0xD1, 0x44, 0x65, 0x13, 0x52, 0x89,
                0xFC, 0xB2, 0x9D, 0xF3, 0xD2, 0xEE, 0xA9, 0x7C, 0x48, 0xAF, 0x59, 0xFF, 0x24, 0x5C, 0x03, 0x2B,
                0x9F, 0x43, 0xA9, 0xB1, 0x15, 0x86, 0xF2, 0x44, 0x14, 0x4A, 0xA9, 0x0A, 0xE2, 0x41, 0x4B, 0x55,
                0xC4, 0x55, 0xBD, 0x7C, 0x02, 0x79, 0xB7, 0xBB, 0xBF, 0x00, 0x00, 0x00, 0x00,
            };
            var expectedStream = DataStreamFactory.FromArray(expected, 0, expected.Length);

            byte[] data =
            {
                0x4C, 0x6F, 0x72, 0x65, 0x6D, 0x20, 0x69, 0x70, 0x73, 0x75, 0x6D, 0x20, 0x64, 0x6F, 0x6C, 0x6F,
                0x72, 0x20, 0x73, 0x69, 0x74, 0x20, 0x61, 0x6D, 0x65, 0x74, 0x2C, 0x20, 0x63, 0x6F, 0x6E, 0x73,
                0x65, 0x63, 0x74, 0x65, 0x74, 0x75, 0x72, 0x20, 0x61, 0x64, 0x69, 0x70, 0x69, 0x73, 0x63, 0x69,
                0x6E, 0x67, 0x20, 0x65, 0x6C, 0x69, 0x74, 0x2E, 0x20, 0x4D, 0x6F, 0x72, 0x62, 0x69, 0x20, 0x70,
                0x68, 0x61, 0x72, 0x65, 0x74, 0x72, 0x61, 0x20, 0x75, 0x74, 0x20, 0x76, 0x65, 0x6C, 0x69, 0x74,
                0x20, 0x65, 0x67, 0x65, 0x74, 0x20, 0x70, 0x6F, 0x72, 0x74, 0x61, 0x2E, 0x20, 0x55, 0x74, 0x20,
                0x75, 0x6C, 0x6C, 0x61, 0x6D, 0x63, 0x6F, 0x72, 0x70, 0x65, 0x72, 0x2C, 0x20, 0x6E, 0x69, 0x62,
                0x68, 0x20, 0x61, 0x20, 0x69, 0x6D, 0x70, 0x65, 0x72, 0x64, 0x69, 0x65, 0x74, 0x20, 0x69, 0x61,
                0x63, 0x75, 0x6C, 0x69, 0x73, 0x2C, 0x20, 0x6D, 0x61, 0x67, 0x6E, 0x61, 0x20, 0x72, 0x69, 0x73,
                0x75, 0x73, 0x20, 0x63, 0x75, 0x72, 0x73, 0x75, 0x73, 0x20, 0x6E, 0x65, 0x71, 0x75, 0x65, 0x2C,
                0x20, 0x65, 0x74, 0x20, 0x73, 0x61, 0x67, 0x69, 0x74, 0x74, 0x69, 0x73, 0x20, 0x6D, 0x61, 0x73,
                0x73, 0x61, 0x20, 0x73, 0x61, 0x70, 0x69, 0x65, 0x6E, 0x20, 0x61, 0x63, 0x20, 0x6E, 0x69, 0x73,
                0x69, 0x2E, 0x20, 0x4D, 0x6F, 0x72, 0x62, 0x69, 0x20, 0x73, 0x69, 0x74, 0x20, 0x61, 0x6D, 0x65,
                0x74, 0x20, 0x65, 0x73, 0x74, 0x20, 0x73, 0x61, 0x67, 0x69, 0x74, 0x74, 0x69, 0x73, 0x2C, 0x20,
                0x70, 0x6F, 0x72, 0x74, 0x61, 0x20, 0x74, 0x6F, 0x72, 0x74, 0x6F, 0x72, 0x20, 0x73, 0x65, 0x64,
                0x2C, 0x20, 0x73, 0x6F, 0x6C, 0x6C, 0x69, 0x63, 0x69, 0x74, 0x75, 0x64, 0x69, 0x6E, 0x20, 0x66,
                0x65, 0x6C, 0x69, 0x73, 0x2E, 0x20, 0x4E, 0x61, 0x6D, 0x20, 0x76, 0x65, 0x73, 0x74, 0x69, 0x62,
                0x75, 0x6C, 0x75, 0x6D, 0x20, 0x6C, 0x69, 0x67, 0x75, 0x6C, 0x61, 0x20, 0x61, 0x74, 0x20, 0x73,
                0x65, 0x6D, 0x70, 0x65, 0x72, 0x20, 0x76, 0x69, 0x76, 0x65, 0x72, 0x72, 0x61, 0x2E, 0x20, 0x50,
                0x68, 0x61, 0x73, 0x65, 0x6C, 0x6C, 0x75, 0x73, 0x20, 0x6E, 0x65, 0x63, 0x20, 0x6C, 0x61, 0x6F,
                0x72, 0x65, 0x65, 0x74, 0x20, 0x70, 0x75, 0x72, 0x75, 0x73, 0x2E, 0x20, 0x4D, 0x61, 0x65, 0x63,
                0x65, 0x6E, 0x61, 0x73, 0x20, 0x76, 0x65, 0x6C, 0x20, 0x70, 0x75, 0x72, 0x75, 0x73, 0x20, 0x69,
                0x6E, 0x74, 0x65, 0x72, 0x64, 0x75, 0x6D, 0x2C, 0x20, 0x62, 0x6C, 0x61, 0x6E, 0x64, 0x69, 0x74,
                0x20, 0x6C, 0x69, 0x62, 0x65, 0x72, 0x6F, 0x20, 0x69, 0x6E, 0x2C, 0x20, 0x67, 0x72, 0x61, 0x76,
                0x69, 0x64, 0x61, 0x20, 0x61, 0x75, 0x67, 0x75, 0x65, 0x2E, 0x20, 0x50, 0x72, 0x6F, 0x69, 0x6E,
                0x20, 0x65, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x75, 0x6D, 0x20, 0x64, 0x75, 0x69, 0x20, 0x69,
                0x64, 0x20, 0x6D, 0x61, 0x67, 0x6E, 0x61, 0x20, 0x74, 0x72, 0x69, 0x73, 0x74, 0x69, 0x71, 0x75,
                0x65, 0x20, 0x73, 0x61, 0x67, 0x69, 0x74, 0x74, 0x69, 0x73, 0x2E, 0x20, 0x4D, 0x61, 0x75, 0x72,
                0x69, 0x73, 0x20, 0x6D, 0x61, 0x78, 0x69, 0x6D, 0x75, 0x73, 0x20, 0x74, 0x72, 0x69, 0x73, 0x74,
                0x69, 0x71, 0x75, 0x65, 0x20, 0x73, 0x65, 0x6D, 0x2C, 0x20, 0x61, 0x63, 0x20, 0x70, 0x6C, 0x61,
                0x63, 0x65, 0x72, 0x61, 0x74, 0x20, 0x6C, 0x65, 0x6F, 0x20, 0x74, 0x65, 0x6D, 0x70, 0x75, 0x73,
                0x20, 0x61, 0x2E, 0x20, 0x41, 0x6C, 0x69, 0x71, 0x75, 0x61, 0x6D, 0x20, 0x6C, 0x65, 0x6F, 0x2E,
            };
            var dataStream = DataStreamFactory.FromArray(data, 0, data.Length);

            var compressor   = new Compressor();
            var binaryFormat = compressor.Convert(new BinaryFormat(dataStream));

            Assert.AreEqual(expected.Length, binaryFormat.Stream.Length);
            Assert.IsTrue(binaryFormat.Stream.Compare(expectedStream));
        }
Exemple #2
0
        public void NullSourceThrowsException()
        {
            var writer = new Compressor();

            Assert.Throws <ArgumentNullException>(() => writer.Convert(null));
        }