public void ReadNextBlockBeforeReadHeader()
        {
            var fileName = Path.Combine(testFolder, "file.bin");

            File.WriteAllBytes(fileName, new byte[20]);
            using (reader = new RsaFileReader(fileName)) {
                Assert.Throws(typeof(InvalidOperationException), () => reader.ReadNextBlock());
            }
        }
        public void ReadNextBlock_ZeroBeforeNumber()
        {
            var fileName = Path.Combine(testFolder, "file.bin");
            var bytes    = new byte[29];

            bytes[1]  = 2;
            bytes[27] = 45;
            bytes[28] = 0;
            File.WriteAllBytes(fileName, bytes);
            using (reader = new RsaFileReader(fileName)) {
                reader.ReadHeader();
                var number         = reader.ReadNextBlock();
                var expectedNumber = BigNumber.FromBytes(new[] { 45 });
                Assert.AreEqual(CompareResult.Equal, expectedNumber.Compare(number));
            }
        }
        public void ReadNextBlock_BlockLengthIs5()
        {
            var fileName = Path.Combine(testFolder, "file.bin");
            var bytes    = new byte[32];

            bytes[1]  = 5;
            bytes[27] = 23;
            bytes[28] = 67;
            bytes[29] = 12;
            bytes[30] = 149;
            bytes[31] = 253;
            File.WriteAllBytes(fileName, bytes);
            using (reader = new RsaFileReader(fileName)) {
                reader.ReadHeader();
                var number         = reader.ReadNextBlock();
                var expectedNumber = BigNumber.FromBytes(new[] { 23, 67, 12, 149, 253 });
                Assert.AreEqual(CompareResult.Equal, expectedNumber.Compare(number));
            }
        }
        public void ReadNextBlock_BlockContainsOnlyZeros()
        {
            var fileName = Path.Combine(testFolder, "file.bin");
            var bytes    = new byte[] {
                0,                                 // version
                4, 0,                              // length of blocks
                1, 0, 0, 0,                        // length of source file
                0, 0, 0, 0,                        // length of source file
                0, 0, 0, 0,                        // hash code
                0, 0, 0, 0,                        // hash code
                0, 0, 0, 0,                        // hash code
                0, 0, 0, 0,                        // hash code
                0, 0, 0, 0                         // first block
            };

            File.WriteAllBytes(fileName, bytes);
            using (reader = new RsaFileReader(fileName)) {
                reader.ReadHeader();
                var number = reader.ReadNextBlock();
                Assert.IsTrue(number.IsZero);
            }
        }