/// <summary>
        ///     Visits the entire tree, calling <see cref="IProjectTreePropertiesProvider.CalculatePropertyValues(IProjectTreeCustomizablePropertyContext, IProjectTreeCustomizablePropertyValues)"/>
        ///     for every node.
        /// </summary>
        public static IProjectTree ChangePropertyValuesForEntireTree(this IProjectTreePropertiesProvider propertiesProvider, IProjectTree tree)
        {
            // Cheat here, because the IProjectTree that we get from ProjectTreeParser is mutable, we want to clone it
            // so that any properties providers changes don't affect the "original" tree. If we implemented a completely
            // immutable tree, then we wouldn't have to do that - but that's currently a lot of work for test-only purposes.
            string treeAsString = ProjectTreeWriter.WriteToString(tree);

            return(ChangePropertyValuesWalkingTree(propertiesProvider, ProjectTreeParser.Parse(treeAsString)));
        }
        private void AssertAreEquivalent(IProjectTree expected, IProjectTree actual)
        {
            Assert.NotSame(expected, actual);

            string expectedAsString = ProjectTreeWriter.WriteToString(expected);
            string actualAsString   = ProjectTreeWriter.WriteToString(actual);

            Assert.Equal(expectedAsString, actualAsString);
        }
        private void AssertProjectTree(string input, string expected, ProjectTreeWriterOptions options = ProjectTreeWriterOptions.Capabilities | ProjectTreeWriterOptions.FilePath | ProjectTreeWriterOptions.Visibility)
        {
            // Remove the newlines from the start and end of input and expected so that
            // it makes it easier inside the test to layout the repro.
            input    = input.Trim(new[] { '\n', '\r' });
            expected = expected.Trim(new[] { '\n', '\r' });

            var parser = new ProjectTreeParser(input);
            var writer = new ProjectTreeWriter(parser.Parse(), options | ProjectTreeWriterOptions.Tags);

            string result = writer.WriteToString();

            Assert.Equal(expected, result, ignoreLineEndingDifferences: true);
        }
Exemplo n.º 4
0
        public static string WriteToString(IProjectTree tree)
        {
            var writer = new ProjectTreeWriter(tree, ProjectTreeWriterOptions.AllProperties);

            return(writer.WriteToString());
        }