Ejemplo n.º 1
0
        public void Parse_ShouldCreateParseTree_WhenCsvStandardSyntaxTreeBuilderIsPassed()
        {
            // Given
            var input       = "one,two\nthree,four";
            var treeVisitor = new CsvStandardSyntaxTreeBuilder(CsvSyntaxTreeFactory.Instance);
            var underTest   = new CsvCompiler();

            // When
            var node   = underTest.Parse(input, treeVisitor) as CsvCompilationUnit;
            var fields = node.ToEnumerable().OfType <FieldDeclarationSyntax>();
            var allOfThemIsTextField = fields.All(field => field.IsTextField);
            var fieldValues          = fields.Select(getTextFromNode);

            // Then
            Assert.That(allOfThemIsTextField, Is.True);
            Assert.That(fieldValues, Is.EquivalentTo(new[]
            {
                "one", "two", "three", "four"
            }));
        }
Ejemplo n.º 2
0
        public void Parse_ShouldCreateParseTree_WhenCsvStandardSyntaxTreeBuilderIsPassed()
        {
            // Given
            var input = "one,two\nthree,four";
            var treeVisitor = new CsvStandardSyntaxTreeBuilder(CsvSyntaxTreeFactory.Instance);
            var underTest = new CsvCompiler();

            // When
            var node = underTest.Parse(input, treeVisitor) as CsvCompilationUnit;
            var fields = node.ToEnumerable().OfType<FieldDeclarationSyntax>();
            var allOfThemIsTextField = fields.All(field => field.IsTextField);
            var fieldValues = fields.Select(getTextFromNode);

            // Then
            Assert.That(allOfThemIsTextField, Is.True);
            Assert.That(fieldValues, Is.EquivalentTo(new[]
            {
                "one", "two", "three", "four"
            }));
        }