Example #1
0
        public void CorrectJsonOutputIsGenerated(TreeDefinition tree, string expectedJson)
        {
            // Create json for the tree
            var writtenJson = tree.ToJson(JsonSerializer.Mode.Normal);

            // Strip whitespace (Easier to define test-data without having to worry about whitespace)
            writtenJson  = writtenJson.Replace(" ", string.Empty, StringComparison.Ordinal);
            expectedJson = expectedJson.Replace(" ", string.Empty, StringComparison.Ordinal);
            expectedJson = expectedJson.Replace("\n", string.Empty, StringComparison.Ordinal);

            // Assert that written and expected json match.
            Assert.Equal(expectedJson, writtenJson);
        }