コード例 #1
0
        /// <summary>
        /// Wrap BotBuilder action into AdaptiveCard submit action.
        /// </summary>
        /// <param name="action"> Target bot builder aciton to be adapted.</param>
        /// <returns> The wrapped adaptive card submit action.</returns>
        public static AdaptiveCards.AdaptiveSubmitAction ToAdaptiveCardAction(this CardAction action)
        {
            var adaptiveCardAction = new AdaptiveCards.AdaptiveSubmitAction();

            adaptiveCardAction.RepresentAsBotBuilderAction(action);
            return(adaptiveCardAction);
        }
コード例 #2
0
        public void CardTests_AdaptiveCard_BotBuilderAction_RepresentAsBotBuilderAction()
        {
            var wrapAction = new CardAction
            {
                Type  = "imback",
                Value = "Text",
                Title = "button title"
            };

            var action = new AdaptiveCards.AdaptiveSubmitAction();

            action.DataJson = @"{""key"": ""value""}";
            action.RepresentAsBotBuilderAction(wrapAction);

            var expectedAction = JsonConvert.DeserializeObject(@"{
                ""type"": ""Action.Submit"",
                ""title"": ""button title"",
                ""data"": {
                    ""key"": ""value"",
                    ""msteams"": {
                        ""type"": ""imback"",
                        ""value"": ""Text""
                    }
                }
            }");

            Assert.IsTrue(JObject.DeepEquals(JObject.FromObject(expectedAction), JObject.FromObject(action)));

            var card = new AdaptiveCards.AdaptiveCard();

            card.Body.Add(new AdaptiveCards.AdaptiveTextBlock());
            card.Actions.Add(action);

            Attachment attachment = card.ToAttachment();

            this.TestCard(attachment);
        }