Exemple #1
0
        public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                await iprot.ReadStructBeginAsync(cancellationToken);

                while (true)
                {
                    field = await iprot.ReadFieldBeginAsync(cancellationToken);

                    if (field.Type == TType.Stop)
                    {
                        break;
                    }

                    switch (field.ID)
                    {
                    case 0:
                        if (field.Type == TType.Struct)
                        {
                            Success = new MessageOperations();
                            await Success.ReadAsync(iprot, cancellationToken);
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 1:
                        if (field.Type == TType.Struct)
                        {
                            E = new TalkException();
                            await E.ReadAsync(iprot, cancellationToken);
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    default:
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                        break;
                    }

                    await iprot.ReadFieldEndAsync(cancellationToken);
                }

                await iprot.ReadStructEndAsync(cancellationToken);
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public Client()
        {
            // Load the requestor
            _requestor = new Requestor();

            // Setup the operations
            AccountOperations = new AccountOperations(_requestor);
            MessageOperations = new MessageOperations(_requestor);
        }
        public void When_replying_message_interface_should_set_interface_as_message_type()
        {
            var replyPipeline = new FakePipeline <IOutgoingReplyContext>();
            var context       = CreateContext(replyPipeline);

            MessageOperations.Reply <IMyMessage>(context, m => { }, new ReplyOptions());

            Assert.That(replyPipeline.ReceivedContext.Message.MessageType, Is.EqualTo(typeof(IMyMessage)));
        }
        public void When_sending_message_class_should_set_class_as_message_type()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);

            MessageOperations.Send <MyMessage>(context, m => { }, new SendOptions());

            Assert.That(sendPipeline.ReceivedContext.Message.MessageType, Is.EqualTo(typeof(MyMessage)));
        }
        public void When_publishing_event_class_should_set_class_as_message_type()
        {
            var publishPipeline = new FakePipeline <IOutgoingPublishContext>();
            var context         = CreateContext(publishPipeline);

            MessageOperations.Publish <MyMessage>(context, m => { }, new PublishOptions());

            Assert.That(publishPipeline.ReceivedContext.Message.MessageType, Is.EqualTo(typeof(MyMessage)));
        }
        public void When_sending_should_generate_message_id_and_set_message_id_header()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);

            MessageOperations.Send <MyMessage>(context, m => { }, new SendOptions());

            var messageId = sendPipeline.ReceivedContext.MessageId;

            Assert.IsNotNull(messageId);
            Assert.AreEqual(messageId, sendPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
        public void When_publishing_should_generate_message_id_and_set_message_id_header()
        {
            var publishPipeline = new FakePipeline <IOutgoingPublishContext>();
            var context         = CreateContext(publishPipeline);

            MessageOperations.Publish <MyMessage>(context, m => { }, new PublishOptions());

            var messageId = publishPipeline.ReceivedContext.MessageId;

            Assert.IsNotNull(messageId);
            Assert.AreEqual(messageId, publishPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
        public void When_replying_should_generate_message_id_and_set_message_id_header()
        {
            var replyPipeline = new FakePipeline <IOutgoingReplyContext>();
            var context       = CreateContext(replyPipeline);

            MessageOperations.Reply <MyMessage>(context, m => { }, new ReplyOptions());

            var messageId = replyPipeline.ReceivedContext.MessageId;

            Assert.IsNotNull(messageId);
            Assert.AreEqual(messageId, replyPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
Exemple #9
0
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 0:
                        if (field.Type == TType.Struct)
                        {
                            Success = new MessageOperations();
                            Success.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 1:
                        if (field.Type == TType.Struct)
                        {
                            E = new TalkException();
                            E.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public void When_sending_with_user_defined_message_id_should_set_defined_id_and_header()
        {
            const string expectedMessageID = "expected message id";

            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);
            var sendOptions  = new SendOptions();

            sendOptions.SetMessageId(expectedMessageID);

            MessageOperations.Send <MyMessage>(context, m => { }, sendOptions);

            Assert.AreEqual(expectedMessageID, sendPipeline.ReceivedContext.MessageId);
            Assert.AreEqual(expectedMessageID, sendPipeline.ReceivedContext.Headers[Headers.MessageId]);
        }
        public void When_sending_should_clone_headers()
        {
            var sendPipeline = new FakePipeline <IOutgoingSendContext>();
            var context      = CreateContext(sendPipeline);
            var sendOptions  = new SendOptions();

            sendOptions.SetHeader("header1", "header1 value");

            MessageOperations.Send <MyMessage>(context, m => { }, sendOptions);
            sendPipeline.ReceivedContext.Headers.Add("header2", "header2 value");
            sendPipeline.ReceivedContext.Headers["header1"] = "updated header1 value";

            var optionsHeaders = sendOptions.GetHeaders();

            Assert.AreEqual(1, optionsHeaders.Count);
            Assert.AreEqual("header1 value", optionsHeaders["header1"]);
        }