AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

Adaptive Card Templating fails rendering cards using culture az-Latn-AZ

Open marcopelegrini opened this issue 3 years ago • 0 comments

Adaptive Card Templating fails rendering cards using culture az-Latn-AZ

See unit tests below:

namespace Microsoft.Tests.Services.CardBuilders
{
    using System.Collections.Generic;
    using System.Globalization;
    using AdaptiveCards.Templating;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Tests Adaptive Cards Templating.
    /// </summary>
    [TestClass]
    public class AdaptiveCardsTemplating
    {
        /// <summary>
        /// Test Rendering AC with Different Locales.
        /// </summary>
        [TestMethod]
        public void TestRenderingAcWithDifferentLocales()
        {
            var cultures = new List<string>
            {
                "en-CA",
                "en-US",
                "fr-FR",
                "pt-BR",
                "az-Latn-AZ",
            };
            cultures.ForEach(TestAndAssert);
        }

        private static void TestAndAssert(string culture)
        {
            CultureInfo.CurrentCulture = new CultureInfo(culture, false);
            const string templateJson = @"
            {
              ""type"": ""AdaptiveCard"",
              ""version"": ""1.4"",
              ""body"": [
                {
                  ""id"": ""correlationId"",
                  ""type"": ""TextBlock"",
                  ""text"": ""${correlationIdText}""
                }
              ]
            }";

            var template = new AdaptiveCardTemplate(templateJson);

            var data = new
            {
                correlationIdText = "47e91b15-2a10-4dbb-9739-196f6fe615f3",
            };

            var cardJson = template.Expand(data);

            const string expectedJson =
                @"{""type"":""AdaptiveCard"",""version"":""1.4"",""body"":[{""id"":""correlationId"",""type"":""TextBlock"",""text"":""47e91b15-2a10-4dbb-9739-196f6fe615f3""}]}";
            Assert.AreEqual(expectedJson, cardJson, $"Rendering not working for culture {culture}");
        }
    }
}

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

marcopelegrini avatar Apr 28 '22 23:04 marcopelegrini