Ejemplo n.º 1
0
        public void Adaptor_Compress_Decompress_By_ByteArray_InParallel() {
            var plainBytes = PlainText.ToBytes();

            Parallel.ForEach(_compressors,
                             compressor => {
                                 var adapter = new CompressAdapter(compressor);

                                 var compressed = adapter.Compress(plainBytes);
                                 var recovery = adapter.Decompress(compressed);
                                 Assert.AreEqual(plainBytes, recovery);
                                 CollectionAssert.AreEqual(plainBytes, recovery);
                             });
        }
Ejemplo n.º 2
0
        public void Adaptor_Compress_Decompress_By_ByteArray_InParallel()
        {
            var plainBytes = PlainText.ToBytes();

            Parallel.ForEach(_compressors,
                             compressor => {
                var adapter = new CompressAdapter(compressor);

                var compressed = adapter.Compress(plainBytes);
                var recovery   = adapter.Decompress(compressed);
                Assert.AreEqual(plainBytes, recovery);
                CollectionAssert.AreEqual(plainBytes, recovery);
            });
        }
Ejemplo n.º 3
0
        public void Adaptor_Compress_Decompress_By_Stream_InParallel() {
            var plainStream = PlainText.ToStream();

            Parallel.ForEach(_compressors,
                             compressor => {
                                 var adapter = new CompressAdapter(compressor);

                                 var compressed = adapter.Compress(plainStream);
                                 var recoveryStream = new MemoryStream(compressed.Length * 2);
                                 adapter.Decompress(compressed, recoveryStream);

                                 // 데이터가 써졌으므로, 다시 원 위치로 설정해줘야 합니다.
                                 recoveryStream.SetStreamPosition();

                                 Assert.IsTrue(recoveryStream.Length > 0);
                                 Assert.AreEqual(PlainText, recoveryStream.ToText());
                             });
        }
Ejemplo n.º 4
0
        public void Adaptor_Compress_Decompress_By_Stream_InParallel()
        {
            var plainStream = PlainText.ToStream();

            Parallel.ForEach(_compressors,
                             compressor => {
                var adapter = new CompressAdapter(compressor);

                var compressed     = adapter.Compress(plainStream);
                var recoveryStream = new MemoryStream(compressed.Length * 2);
                adapter.Decompress(compressed, recoveryStream);

                // 데이터가 써졌으므로, 다시 원 위치로 설정해줘야 합니다.
                recoveryStream.SetStreamPosition();

                Assert.IsTrue(recoveryStream.Length > 0);
                Assert.AreEqual(PlainText, recoveryStream.ToText());
            });
        }