public void CardTests_AdaptiveCard_JsonToAttachment()
        {
            AdaptiveCards.AdaptiveCardParseResult card = AdaptiveCards.AdaptiveCard.FromJson(File.ReadAllText(@"Jsons\SampleAdaptiveCard.json"));
            Attachment attachment = card.ToAttachment();

            AdaptiveCards.AdaptiveCard expectedCard = new AdaptiveCards.AdaptiveCard();
            expectedCard.Body.Add(new AdaptiveCards.AdaptiveTextBlock("some text on card"));

            var action = new AdaptiveCards.AdaptiveOpenUrlAction();

            action.Url = new Uri("https://microsoft.com");
            expectedCard.Actions.Add(action);

            Assert.IsNotNull(attachment);
            Assert.IsNotNull(attachment.Content);
            Assert.IsNotNull(attachment.ContentType);
            Assert.AreEqual(attachment.ContentType, AdaptiveCards.AdaptiveCard.ContentType);
            Assert.IsTrue(JObject.DeepEquals(JObject.FromObject(expectedCard), JObject.FromObject(attachment.Content)));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new attachment from AdaptiveCardParseResult.
 /// </summary>
 /// <param name="cardParsedResult"> The instance of AdaptiveCardParseResult that represents results parsed from JSON string.</param>
 /// <returns> The generated attachment.</returns>
 public static Attachment ToAttachment(this AdaptiveCards.AdaptiveCardParseResult cardParsedResult)
 {
     return(cardParsedResult.Card.ToAttachment());
 }