public void Fallback() { AdaptiveTextBlock textBlockDrop = new AdaptiveTextBlock { Text = "This text block has fallback type Drop", FallbackType = FallbackType.Drop }; textBlockDrop.Requirements.Add(new AdaptiveRequirement("foo", "1.2.3.4")); Assert.AreEqual(FallbackType.Drop, textBlockDrop.FallbackType); var jsonString = textBlockDrop.ToJson().ToString(); Assert.AreEqual("{\"fallback\":\"drop\",\"requires\":{\"foo\":\"1.2.3.4\"},\"text\":\"This text block has fallback type Drop\",\"type\":\"TextBlock\"}", jsonString); AdaptiveTextBlock textBlockNone = new AdaptiveTextBlock { Text = "This text block has fallback explicitly set to None", FallbackType = FallbackType.None }; textBlockNone.Requirements.Add(new AdaptiveRequirement("foo", "*")); Assert.AreEqual(FallbackType.None, textBlockNone.FallbackType); jsonString = textBlockNone.ToJson().ToString(); Assert.AreEqual("{\"requires\":{\"foo\":\"0.0.0.0\"},\"text\":\"This text block has fallback explicitly set to None\",\"type\":\"TextBlock\"}", jsonString); }
public void TextBlock() { AdaptiveTextBlock textBlock = new AdaptiveTextBlock { Color = ForegroundColor.Accent, FontStyle = FontStyle.Monospace, Height = HeightType.Stretch, HorizontalAlignment = HAlignment.Center, Id = "TextBlockId", IsSubtle = true, IsVisible = false, Italic = true, Language = "en", MaxLines = 3, Separator = true, Size = TextSize.Large, Spacing = Spacing.Large, Strikethrough = true, Text = "This is a text block", Weight = TextWeight.Bolder, Wrap = true }; ValidateBaseElementProperties(textBlock, "TextBlockId", false, true, Spacing.Large, HeightType.Stretch); Assert.AreEqual(ForegroundColor.Accent, textBlock.Color); Assert.AreEqual(FontStyle.Monospace, textBlock.FontStyle); Assert.AreEqual(HAlignment.Center, textBlock.HorizontalAlignment); Assert.IsTrue(textBlock.IsSubtle); Assert.IsTrue(textBlock.Italic); Assert.IsTrue(textBlock.Strikethrough); Assert.AreEqual("en", textBlock.Language); Assert.AreEqual <uint>(3, textBlock.MaxLines); Assert.AreEqual(TextSize.Large, textBlock.Size); Assert.AreEqual("This is a text block", textBlock.Text); Assert.AreEqual(TextWeight.Bolder, textBlock.Weight); Assert.IsTrue(textBlock.Wrap); var jsonString = textBlock.ToJson().ToString(); Assert.AreEqual("{\"color\":\"Accent\",\"fontStyle\":\"Monospace\",\"height\":\"Stretch\",\"horizontalAlignment\":\"center\",\"id\":\"TextBlockId\",\"isSubtle\":true,\"isVisible\":false,\"italic\":true,\"maxLines\":3,\"separator\":true,\"size\":\"Large\",\"spacing\":\"large\",\"strikethrough\":true,\"text\":\"This is a text block\",\"type\":\"TextBlock\",\"weight\":\"Bolder\",\"wrap\":true}", jsonString); }