Esempio n. 1
0
        public void Base16GetCharsAndGetBytesUpTo2048Bytes()
        {
            var random = new Random(10);

            for (int blockSize = 0; blockSize < 2048; blockSize++)
            {
                byte[] block = new byte[blockSize];
                for (int iIndex = 0; iIndex < blockSize; iIndex++)
                {
                    block[iIndex] = (byte)random.Next(256);
                }

                string encodedText = Codec.GetString(block);
                Assert.IsNotNull(encodedText);

                byte[] decodedBytes = Codec.GetBytes(encodedText);
                CollectionAssert.AreEqual(block, decodedBytes);
            }
        }
Esempio n. 2
0
        private static void StreamingTest(BinaryCodec codec, int maxSize)
        {
            for (int currentSize = 0; currentSize <= maxSize; currentSize++)
            {
                var inputData         = GenerateData(currentSize);
                var encodedData       = EncodeThroughStream(codec, inputData);
                var writerDecodedData = DecodeThroughTextWriter(codec, encodedData);

                Assert.AreEqual(currentSize, writerDecodedData.Length, "Writer Decoded Length != input length");
                CollectionAssert.AreEqual(inputData, writerDecodedData, "Writer Decoded Data != input data");

                var outputData = codec.GetBytes(encodedData);

                Assert.AreEqual(outputData.Length, inputData.Length, "Output and Input must be same length.");
                CollectionAssert.AreEqual(inputData, outputData, "Output and Input data differ.");

                var decodedData = DecodeThroughStream(codec, encodedData);

                Assert.AreEqual(inputData.Length, decodedData.Length, "Decoded and Input length must match.");
                CollectionAssert.AreEqual(inputData, decodedData, "Decoded and Input data differ.");
            }
        }