public void ToStringTest() { Assembly assembly = typeof(AggregationHashChain).Assembly; Type linkType = assembly.GetType("Guardtime.KSI.Signature.CalendarHashChain+Link"); ExtendResponsePayload tag = TestUtil.GetCompositeTag <ExtendResponsePayload>(Constants.ExtendResponsePayload.TagType, new ITlvTag[] { new IntegerTag(Constants.PduPayload.RequestIdTagType, false, false, 2), new IntegerTag(Constants.PduPayload.StatusTagType, false, false, 0), new StringTag(Constants.PduPayload.ErrorMessageTagType, false, false, "Test error message."), new IntegerTag(Constants.ExtendResponsePayload.CalendarLastTimeTagType, false, false, 1), TestUtil.GetCompositeTag <CalendarHashChain>(Constants.CalendarHashChain.TagType, new ITlvTag[] { new IntegerTag(Constants.CalendarHashChain.PublicationTimeTagType, false, false, 1), new IntegerTag(Constants.CalendarHashChain.AggregationTimeTagType, false, false, 0), new ImprintTag(Constants.CalendarHashChain.InputHashTagType, false, false, new DataHash(HashAlgorithm.Sha2256, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 })), // add links (ITlvTag)Activator.CreateInstance(linkType, new ImprintTag((uint)LinkDirection.Left, false, false, new DataHash(HashAlgorithm.Sha2256, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }))) }) }); ExtendResponsePayload tag2 = new ExtendResponsePayload(new RawTag(tag.Type, tag.NonCritical, tag.Forward, tag.EncodeValue())); Assert.AreEqual(tag.ToString(), tag2.ToString()); }
public void ExtendResponsePayloadTest() { ExtendResponsePayload payload = new ExtendResponsePayload(new TlvTagBuilder(Constants.ExtendResponsePayload.TagType, false, false, new ITlvTag[] { new IntegerTag(Constants.PduPayload.StatusTagType, false, false, 1), new IntegerTag(Constants.PduPayload.RequestIdTagType, false, false, 2), new IntegerTag(Constants.ExtendResponsePayload.CalendarLastTimeTagType, false, false, 3), }).BuildTag()); Assert.AreEqual(1, payload.Status, "Unexpected status"); Assert.AreEqual(2, payload.RequestId, "Unexpected request id"); Assert.AreEqual(3, payload.CalendarLastTime, "Unexpected calendar last time"); }