public void Convert_TemplateMessageWithCustomIConfirmTemplate_ConvertedToConfirmTemplate()
        {
            TestTemplateMessage message = new TestTemplateMessage()
            {
                Template = new TestConfirmTemplate()
            };

            ISendMessage[] messages = MessageConverter.Convert(new ISendMessage[] { message });

            Assert.AreEqual(1, messages.Length);
            Assert.AreNotEqual(message, messages[0]);

            TemplateMessage templateMessage = messages[0] as TemplateMessage;

            Assert.AreEqual("AlternativeText", templateMessage.AlternativeText);

            ConfirmTemplate template = templateMessage.Template as ConfirmTemplate;

            Assert.AreEqual("ConfirmText", template.Text);

            MessageAction okAction = template.OkAction as MessageAction;

            Assert.AreEqual("MessageLabel", okAction.Label);
            Assert.AreEqual("MessageText", okAction.Text);

            UriAction cancelAction = template.CancelAction as UriAction;

            Assert.AreEqual("UriLabel", cancelAction.Label);
            Assert.AreEqual(new Uri("tel://uri"), cancelAction.Url);
        }
        public void Convert_TemplateMessageWithCustomIButtonsTemplate_ConvertedToConfirmTemplate()
        {
            TestTemplateMessage message = new TestTemplateMessage()
            {
                Template = new TestButtonsTemplate()
            };

            ISendMessage[] messages = MessageConverter.Convert(new ISendMessage[] { message });

            Assert.AreEqual(1, messages.Length);
            Assert.AreNotEqual(message, messages[0]);

            TemplateMessage templateMessage = messages[0] as TemplateMessage;

            Assert.AreEqual("AlternativeText", templateMessage.AlternativeText);

            ButtonsTemplate template = templateMessage.Template as ButtonsTemplate;

            Assert.AreEqual(new Uri("https://bar.foo"), template.ThumbnailUrl);
            Assert.AreEqual("ButtonsTitle", template.Title);
            Assert.AreEqual("ButtonsText", template.Text);

            ITemplateAction[] actions = template.Actions.ToArray();

            PostbackAction action = actions[0] as PostbackAction;

            Assert.AreEqual("PostbackLabel", action.Label);
            Assert.AreEqual("PostbackData", action.Data);
            Assert.AreEqual("PostbackText", action.Text);
        }
        public void Convert_TemplateMessageWithCustomICarouselTemplate_ConvertedToCarouselTemplate()
        {
            TestTemplateMessage message = new TestTemplateMessage()
            {
                Template = new TestCarouselTemplate()
            };

            ISendMessage[] messages = MessageConverter.Convert(new ISendMessage[] { message });

            Assert.AreEqual(1, messages.Length);
            Assert.AreNotEqual(message, messages[0]);

            TemplateMessage templateMessage = messages[0] as TemplateMessage;

            Assert.AreEqual("AlternativeText", templateMessage.AlternativeText);

            CarouselTemplate template = templateMessage.Template as CarouselTemplate;

            CarouselColumn column = template.Columns.First() as CarouselColumn;

            Assert.AreEqual(new Uri("https://carousel.url"), column.ThumbnailUrl);
            Assert.AreEqual("CarouselTitle", column.Title);
            Assert.AreEqual("CarouselText", column.Text);

            ITemplateAction[] actions = column.Actions.ToArray();

            MessageAction action = actions[0] as MessageAction;

            Assert.AreEqual("MessageLabel", action.Label);
            Assert.AreEqual("MessageText", action.Text);
        }
            public void ShouldConvertCustomITemplateMessageToTemplateMessage()
            {
                var message = new TestTemplateMessage()
                {
                    Template = new TestButtonsTemplate()
                };

                var templateMessage = TemplateMessage.Convert(message);

                Assert.AreNotEqual(message, templateMessage);

                Assert.AreEqual("AlternativeText", templateMessage.AlternativeText);

                var template = templateMessage.Template as ButtonsTemplate;

                Assert.AreEqual(new Uri("https://bar.foo"), template.ThumbnailUrl);
                Assert.AreEqual("ButtonsTitle", template.Title);
                Assert.AreEqual("ButtonsText", template.Text);

                var actions = template.Actions.ToArray();

                var action = actions[0] as PostbackAction;

                Assert.AreEqual("PostbackLabel", action.Label);
                Assert.AreEqual("PostbackData", action.Data);
                Assert.AreEqual("PostbackText", action.Text);
            }
        public void Convert_TemplateMessageInvalidTemplateType_ThrowsException()
        {
            TestTemplateMessage message = new TestTemplateMessage()
            {
                Template = new InvalidTemplate()
            };

            ExceptionAssert.Throws <NotSupportedException>("Invalid template type.", () =>
            {
                MessageConverter.Convert(new ISendMessage[] { message });
            });
        }
            public void ShouldThrowExceptionWhenTemplateIsInvalid()
            {
                var message = new TestTemplateMessage()
                {
                    Template = new InvalidTemplate()
                };

                ExceptionAssert.Throws <NotSupportedException>("Invalid template type.", () =>
                {
                    TemplateMessage.Convert(message);
                });
            }