示例#1
0
        public void WithFilePath_DummyTree()
        {
            var oldTree = new CSharpSyntaxTree.DummySyntaxTree();
            var newTree = oldTree.WithFilePath("new.cs");

            Assert.Equal("new.cs", newTree.FilePath);
            Assert.Equal(oldTree.ToString(), newTree.ToString());
        }
        public void WithFilePath_DummyTree()
        {
            var oldTree = new CSharpSyntaxTree.DummySyntaxTree();
            var newTree = oldTree.WithFilePath("new.cs");

            Assert.Equal(newTree.FilePath, "new.cs");
            Assert.Equal(oldTree.ToString(), newTree.ToString());
        }
示例#3
0
 public void WithRootAndOptions_DummyTree()
 {
     var dummy = new CSharpSyntaxTree.DummySyntaxTree();
     var newRoot = SyntaxFactory.ParseCompilationUnit("class C {}");
     var newOptions = new CSharpParseOptions();
     var newTree = dummy.WithRootAndOptions(newRoot, newOptions);
     Assert.Equal(newRoot.ToString(), newTree.GetRoot().ToString());
     Assert.Same(newOptions, newTree.Options);
 }
示例#4
0
        public void WithFilePath_Null()
        {
            SyntaxTree oldTree = new CSharpSyntaxTree.DummySyntaxTree();

            Assert.Equal(string.Empty, oldTree.WithFilePath(null).FilePath);
            oldTree = SyntaxFactory.ParseSyntaxTree("", path: "old.cs");
            Assert.Equal(string.Empty, oldTree.WithFilePath(null).FilePath);
            Assert.Equal(string.Empty, SyntaxFactory.ParseSyntaxTree("", path: null).FilePath);
            Assert.Equal(string.Empty, CSharpSyntaxTree.Create((CSharpSyntaxNode)oldTree.GetRoot(), path: null).FilePath);
        }
示例#5
0
        public void WithRootAndOptions_DummyTree()
        {
            var dummy      = new CSharpSyntaxTree.DummySyntaxTree();
            var newRoot    = SyntaxFactory.ParseCompilationUnit("class C {}");
            var newOptions = new CSharpParseOptions();
            var newTree    = dummy.WithRootAndOptions(newRoot, newOptions);

            Assert.Equal(newRoot.ToString(), newTree.GetRoot().ToString());
            Assert.Same(newOptions, newTree.Options);
        }
示例#6
0
 public void WithFilePath_Null()
 {
     SyntaxTree oldTree = new CSharpSyntaxTree.DummySyntaxTree();
     Assert.Equal(string.Empty, oldTree.WithFilePath(null).FilePath);
     oldTree = SyntaxFactory.ParseSyntaxTree("", path: "old.cs");
     Assert.Equal(string.Empty, oldTree.WithFilePath(null).FilePath);
     Assert.Equal(string.Empty, SyntaxFactory.ParseSyntaxTree("", path: null).FilePath);
     Assert.Equal(string.Empty, CSharpSyntaxTree.Create((CSharpSyntaxNode)oldTree.GetRoot(), path: null).FilePath);
 }