public void HASignWithInvalidResultTlvFailTest()
        {
            IKsiService haService =
                new HAKsiService(
                    new List <IKsiService>()
            {
                GetStaticKsiService(File.ReadAllBytes(Path.Combine(TestSetup.LocalPath, Resources.KsiService_AggregatorConfigResponsePdu)),
                                    1584727637)
            },
                    null, null);

            HAKsiServiceException ex = Assert.Throws <HAKsiServiceException>(delegate
            {
                HAAsyncResult asyncResult = (HAAsyncResult)haService.BeginSign(new DataHash(Base16.Decode("019f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08")),
                                                                               null, null);

                // add invalid result
                FieldInfo memberInfo  = typeof(HARequestRunner).GetField("_resultTlvs", BindingFlags.NonPublic | BindingFlags.Instance);
                List <object> results = (List <object>)memberInfo.GetValue(asyncResult.RequestRunner);
                results.Add(new IntegerTag(1, false, false, 1));

                haService.EndSign(asyncResult);
            });

            Assert.That(ex.Message.StartsWith("Could not get request response of type " + typeof(KsiSignature)), "Unexpected exception message: " + ex.Message);
        }
Exemple #2
0
        public void HAExtendWithInvalidResultTlvFailTest()
        {
            IKsiService haService =
                new HAKsiService(
                    null,
                    new List <IKsiService>()
            {
                GetStaticKsiService(File.ReadAllBytes(Path.Combine(TestSetup.LocalPath, Resources.KsiService_ExtenderConfigResponsePdu)), 1043101455)
            },
                    null);

            HAKsiServiceException ex = Assert.Throws <HAKsiServiceException>(delegate
            {
                HAAsyncResult ar = (HAAsyncResult)haService.BeginExtend(1455494400, null, null);

                // add invalid result
                FieldInfo memberInfo  = typeof(HARequestRunner).GetField("_resultTlvs", BindingFlags.NonPublic | BindingFlags.Instance);
                List <object> results = (List <object>)memberInfo.GetValue(ar.RequestRunner);
                results.Add(new IntegerTag(1, false, false, 1));
                haService.EndExtend(ar);
            });

            Assert.That(ex.Message.StartsWith("Could not get request response of type " + typeof(CalendarHashChain)), "Unexpected exception message: " + ex.Message);
        }