Ejemplo n.º 1
0
        public async Task SendWithJsonHttpContentShouldSucceed()
        {
            // Arrange
            Registrator.RegisterDocuments();
            var destination = new Identity(Guid.NewGuid().ToString(), "msging.net");

            Context.User.Returns(destination);
            var select = new Select()
            {
                Text    = "This is the header",
                Scope   = SelectScope.Immediate,
                Options = new[]
                {
                    new SelectOption
                    {
                        Text = "This is the first option"
                    },
                    new SelectOption
                    {
                        Text = "This is the second option"
                    },
                    new SelectOption
                    {
                        Text = "This is the third option"
                    }
                }
            };

            var content = DocumentSerializer.Serialize(select);


            var settings = new SendRawMessageSettings
            {
                Type       = Select.MIME_TYPE,
                RawContent = content
            };
            var target = GetTarget();

            // Act
            await target.ExecuteAsync(Context, JObject.FromObject(settings), CancellationToken);

            // Assert
            await Sender.Received(1).SendMessageAsync(
                Arg.Is <Message>(m =>
                                 m.To.ToIdentity().Equals(destination) &&
                                 m.Type == Select.MediaType &&
                                 m.Content is Select &&
                                 ((Select)m.Content).Text == select.Text &&
                                 ((Select)m.Content).Scope == SelectScope.Immediate &&
                                 ((Select)m.Content).Options.Length == select.Options.Length &&
                                 ((Select)m.Content).Options[0].Text == select.Options[0].Text &&
                                 ((Select)m.Content).Options[1].Text == select.Options[1].Text &&
                                 ((Select)m.Content).Options[2].Text == select.Options[2].Text),
                CancellationToken);
        }
Ejemplo n.º 2
0
        public async Task SendWithPlainHttpContentShouldSucceed()
        {
            // Arrange
            var content  = "This is a text content";
            var settings = new SendRawMessageSettings()
            {
                Type       = PlainText.MIME_TYPE,
                RawContent = content
            };
            var target = GetTarget();

            // Act
            await target.ExecuteAsync(Context, JObject.FromObject(settings), CancellationToken);

            // Assert
            await Sender.Received(1).SendMessageAsync(Arg.Is <Message>(m =>
                                                                       m.To.Equals(From) && m.Type == PlainText.MediaType && m.Content.ToString().Equals(content)), CancellationToken);
        }