GetReader() 공개 메소드

Gets a TextReader for this test file.
public GetReader ( ) : TextReader
리턴 TextReader
예제 #1
0
        public void TestAutoPropertyInitializersParseCorrectly()
        {
            CSharpTestFile testFile = CSharpTestUtilities.GetAutoPropertyInitializersFile();

            using (TextReader reader = testFile.GetReader())
            {
                CSharpParser parser = new CSharpParser();
                ReadOnlyCollection <ICodeElement> elements = parser.Parse(reader);
                elements.Should().HaveCount(1, "because there is only one namespace");
                elements[0].Children.Should().HaveCount(1, "because there is 1 class in the namespace");
                elements[0].Children[0].Children.Should().HaveCount(4, "because there are 4 subclasses in the class");
                var customer1 = elements[0].Children[0].Children[0];
                var customer2 = elements[0].Children[0].Children[1];
                var customer3 = elements[0].Children[0].Children[2];
                var customer4 = elements[0].Children[0].Children[3];
                customer1.Children.Should().HaveCount(2, "because there are only 2 properties");
                customer1.Children[0].ElementType.Should().Be(ElementType.Property);
                customer1.Children[1].ElementType.Should().Be(ElementType.Property);
                customer2.Children.Should().HaveCount(2, "because there are only 2 properties");
                customer2.Children[0].ElementType.Should().Be(ElementType.Property);
                customer2.Children[1].ElementType.Should().Be(ElementType.Property);
                customer3.Children.Should().HaveCount(2, "because there is only 1 property and 1 constructor");
                customer3.Children[0].ElementType.Should().Be(ElementType.Property);
                customer3.Children[1].ElementType.Should().Be(ElementType.Constructor);
                customer4.Children.Should().HaveCount(2, "because there are only 2 properties");
                customer4.Children[0].ElementType.Should().Be(ElementType.Property);
                customer4.Children[1].ElementType.Should().Be(ElementType.Property);
            }
        }
예제 #2
0
        public void TestFixtureSetup()
        {
            CSharpTestFile testFile = CSharpTestUtilities.GetClassMembersFile();

            using (TextReader reader = testFile.GetReader())
            {
                CSharpParser parser = new CSharpParser();
                _testElements = parser.Parse(reader);

                Assert.IsTrue(_testElements.Count > 0, "Test file does not contain any elements.");
            }
        }
예제 #3
0
        public void TestExpressionPropertyWithGreaterThanSignInBody()
        {
            CSharpTestFile testFile = CSharpTestUtilities.GetExpressionBodyFile();

            using (TextReader reader = testFile.GetReader())
            {
                CSharpParser parser = new CSharpParser();
                ReadOnlyCollection <ICodeElement> elements = parser.Parse(reader);
                var bugfix = elements[2].Children[0].Children[3];
                bugfix.Name.Should().Be("Bugfix");
                bugfix.Children.Should().HaveCount(2, "because there are only 2 properties");
                bugfix.Children[0].ElementType.Should().Be(ElementType.Property);
                bugfix.Children[1].ElementType.Should().Be(ElementType.Property);
                ((PropertyElement)bugfix.Children[1]).ExpressionBodyText.Should().Be("Value > 10");
            }
        }