public void VerifySinglePageJSONExport() { App.Content = new SimplePage(); var exporter = new JsonExporter(new StandardObjectToStringConverter()); var snapshotCreator = new ElementSnapshotCreator(StandardOptions.StandardPropertyNames, App.Content); var export = exporter.CreateJsonObject(snapshotCreator.CreateSnapshot(), false, true); Assert.IsNotNull(export); var jsonAsText = export.Stringify(); Assert.IsTrue(jsonAsText.Contains("VisualTreeAnalyzers.Tests.TestInfra.DemoVisualTrees.SimplePage")); Assert.IsTrue(jsonAsText.Contains("\"type\":\"Windows.UI.Xaml.Controls.Grid\",\"Name\":\"RootGrid\"")); }
public void VerifySingleWUXCControlIsCorrectNoConverterNoNullValues() { App.Content = new TextBlock() { Text = "Some text", Foreground = new SolidColorBrush(Colors.DarkGreen) }; var exporter = new JsonExporter(null); var snapshotCreator = new ElementSnapshotCreator(StandardOptions.StandardPropertyNames, App.Content); var export = exporter.CreateJsonObject(snapshotCreator.CreateSnapshot(), false, true); Assert.IsNotNull(export); Assert.AreEqual("Windows.UI.Xaml.Controls.TextBlock", export.GetNamedString("type")); var jsonAsText = export.Stringify(); Assert.IsTrue(jsonAsText.Contains("\"Visibility\":\"Visible\"")); Assert.IsTrue(jsonAsText.Contains("\"Margin\":\"0,0,0,0\"")); Assert.IsTrue(jsonAsText.Contains("\"Padding\":\"0,0,0,0\"")); Assert.IsFalse(jsonAsText.Contains("\"Background\"")); // Background should not be present in the export as it was not set. Assert.IsTrue(jsonAsText.Contains($"\"Foreground\":\"Windows.UI.Xaml.Media.SolidColorBrush\"")); }
public void VerifySingleWUXCControlIsCorrectDefaultOptions() { App.Content = new TextBlock() { Text = "Some text", Foreground = new SolidColorBrush(Colors.DarkGreen) }; var exporter = new JsonExporter(); var snapshotCreator = new ElementSnapshotCreator(StandardOptions.StandardPropertyNames, App.Content); var export = exporter.CreateJsonObject(snapshotCreator.CreateSnapshot(), true, false); Assert.IsNotNull(export); Assert.AreEqual("TextBlock", export.GetNamedString("type")); var jsonAsText = export.Stringify(); Assert.IsTrue(jsonAsText.Contains("\"Visibility\":\"Visible\"")); Assert.IsTrue(jsonAsText.Contains("\"Margin\":\"0,0,0,0\"")); Assert.IsTrue(jsonAsText.Contains("\"Padding\":\"0,0,0,0\"")); Assert.IsTrue(jsonAsText.Contains("\"Background\":\"[null]\"")); Assert.IsTrue(jsonAsText.Contains($"\"Foreground\":\"{Colors.DarkGreen}\"")); }