Пример #1
0
        public void SingleThreadShouldBeOk()
        {
            var sourceData = this.CreateRandomBytes(1024 * 1024 * 4);

            using (var pipedCoder = new MultiThreadPipedCoder <SynchronizedStreamConnector>(new CopyCoder(1024)))
                using (var inStream = new MemoryStream(sourceData, false))
                    using (var outStream = new MemoryStream())
                    {
                        //Yeah, let's do some multithreaded encoding:
                        pipedCoder.Code(inStream, outStream, -1, -1);
                        Assert.Equal(inStream.Length, outStream.Length);
                        Assert.Equal(inStream.ToArray(), outStream.ToArray());
                    }
        }
Пример #2
0
        public void Test4ThreadsCoder()
        {
            var sourceData = this.CreateRandomBytes(1024 * 1024 * 4);
            var xorKey     = (byte)0x12;

            using (var pipedCoder = new MultiThreadPipedCoder <SynchronizedStreamConnector>(new CopyCoder(1024), new XorCoder(xorKey, 512), new CopyCoder(2048), new XorCoder(xorKey, 4096)))
                using (var inStream = new MemoryStream(sourceData, false))
                    using (var outStream = new MemoryStream())
                    {
                        //Yeah, let's do some multithreaded encoding:
                        pipedCoder.Code(inStream, outStream, -1, -1);
                        Assert.Equal(inStream.Length, outStream.Length);
                        Assert.Equal(inStream.ToArray(), outStream.ToArray());
                    }
        }