public void CreateFromPartsTest()
        {
            KsiSignatureFactory signatureFactory = new KsiSignatureFactory();
            IKsiSignature       signature;

            using (FileStream stream = new FileStream(Path.Combine(TestSetup.LocalPath, Resources.KsiSignature_Ok), FileMode.Open))
            {
                signature = new KsiSignatureFactory().Create(stream);
            }

            IKsiSignature newSignature = signatureFactory.Create(signature.GetAggregationHashChains(), signature.CalendarHashChain, signature.CalendarAuthenticationRecord,
                                                                 signature.PublicationRecord,
                                                                 signature.Rfc3161Record, signature.InputHash);

            Assert.AreEqual(signature.EncodeValue(), newSignature.EncodeValue(), "Signatures should be equal.");
        }
        public void CreateFromPartsWithoutCalendarHashChainFailTest()
        {
            KsiSignatureFactory signatureFactory = new KsiSignatureFactory();
            IKsiSignature       signature;

            using (FileStream stream = new FileStream(Path.Combine(TestSetup.LocalPath, Resources.KsiSignature_Ok), FileMode.Open))
            {
                signature = new KsiSignatureFactory().Create(stream);
            }

            // create signature without calendar hash chain but with calendar auth record.
            TlvException ex = Assert.Throws <TlvException>(delegate
            {
                signatureFactory.Create(signature.GetAggregationHashChains(), null, signature.CalendarAuthenticationRecord, signature.PublicationRecord,
                                        signature.Rfc3161Record, signature.InputHash);
            });

            Assert.That(ex.Message, Does.StartWith("No publication record or calendar authentication record is allowed in KSI signature if there is no calendar hash chain"));
        }