Пример #1
0
        public void ToStringAndName([Values] XZLevel level)
        {
            XZCodec codec = new XZCodec(level);

            Assert.AreEqual("xz", codec.GetName());
            Assert.AreEqual($"xz-{(int)level}", codec.ToString());
        }
Пример #2
0
        public void Equal([Values] XZLevel level)
        {
            XZCodec codec1 = new XZCodec(level);
            XZCodec codec2 = new XZCodec(level);

            Assert.IsTrue(codec1.Equals(codec1));
            Assert.IsTrue(codec2.Equals(codec2));
            Assert.IsTrue(codec1.Equals(codec2));
            Assert.IsTrue(codec2.Equals(codec1));
        }
Пример #3
0
        public void CompressDecompress([ValueSource(nameof(_testLengths))] int length, [Values] XZLevel level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            XZCodec codec = new XZCodec(level);

            byte[] compressed   = codec.Compress(data);
            byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

            Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
        }
Пример #4
0
        public void CompressDecompressStream([ValueSource(nameof(_testLengths))] int length, [Values] XZLevel level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            XZCodec codec = new XZCodec(level);

            using (MemoryStream inputStream = new MemoryStream(data))
                using (MemoryStream outputStream = new MemoryStream())
                {
                    codec.Compress(inputStream, outputStream);

                    byte[] compressed   = outputStream.ToArray();
                    byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

                    Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
                }
        }
Пример #5
0
        public void HashCode([Values] XZLevel level)
        {
            XZCodec codec = new XZCodec(level);

            Assert.AreNotEqual(0, codec.GetHashCode());
        }
Пример #6
0
        public void DefaultLevel()
        {
            XZCodec codec = new XZCodec();

            Assert.AreEqual(XZLevel.Default, codec.Level);
        }