Exemple #1
0
 public void Should_compile_example_code_without_exception(string inputLiteral)
 {
     var inputCode   = CreateCodeWithFieldDefinitionFromLiteral(inputLiteral);
     var tokenStream = GetTokenStream(inputCode);
     var parser      = new CqrsParser(tokenStream);
     var dictionary  = parser.dictionary();
 }
        public void Should_return_one_namespace_assignment(string input)
        {
            var tokenStream = GetTokenStream(input);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();

            Assert.Single(dictionary.GetAllNamespaceAssignments(0));
        }
        public void Should_return_full_namespace_name_with_underscore()
        {
            var tokenStream = GetTokenStream(NAMESPACE_UNDERSCORE);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetNamespaceAssignmentContextItem(0, 0);

            Assert.Equal(UNDERSCORE_NAMESPACE_NAME, assignment.GetNamespaceText());
        }
        public void Should_return_full_namespace_name_with_period()
        {
            var tokenStream = GetTokenStream(NAMESPACE_PERIOD);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetNamespaceAssignmentContextItem(0, 0);

            Assert.Equal(PERIOD_NAMESPACE_NAME, assignment.GetNamespaceText());
        }
        public void Should_return_test_namespace_name(string input)
        {
            var tokenStream = GetTokenStream(input);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetNamespaceAssignmentContextItem(0, 0);

            Assert.Equal(NAMESPACE_NAME, assignment.GetNamespaceText());
        }
        public void Should_return_full_project_name_with_underscore()
        {
            var tokenStream = GetTokenStream(PROJECT_UNDERSCORE);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetProjectAssignmentItem(0);

            Assert.Equal(UNDERSCORE_PROJECT_NAME, assignment.GetProjectNameText());
        }
        public void Should_return_full_project_name_with_period()
        {
            var tokenStream = GetTokenStream(PROJECT_PERIOD);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetProjectAssignmentItem(0);

            Assert.Equal(PERIOD_PROJECT_NAME, assignment.GetProjectNameText());
        }
        public void Should_return_test_project_name(string input)
        {
            var tokenStream = GetTokenStream(input);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();
            var assignment  = dictionary.GetProjectAssignmentItem(0);

            Assert.Equal(PROJECT_NAME, assignment.GetProjectNameText());
        }
Exemple #9
0
        static void Main(string[] args)
        {
            var file              = File.ReadAllText("Example.cqrsx");
            var inputStream       = new AntlrInputStream(file);
            var lexer             = new CqrsLexer(inputStream);
            var commonTokenStream = new CommonTokenStream(lexer);

            var parser        = new CqrsParser(commonTokenStream);
            var errorListener = new ConsoleErrorListener <IToken>();

            parser.AddErrorListener(errorListener);

            var languageVisitor = new CqrsDataModelVisitor();
            var model           = languageVisitor.Visit(parser.dictionary());

            Console.ReadKey();
        }
Exemple #10
0
        public void Should_return_field1_as_being_predefined_type(string inputLiteral)
        {
            var inputCode   = CreateCodeWithFieldDefinitionFromLiteral(inputLiteral);
            var tokenStream = GetTokenStream(inputCode);
            var parser      = new CqrsParser(tokenStream);
            var dictionary  = parser.dictionary();

            var namespaceAssignment = dictionary.GetNamespaceAssignmentContextItem(0, 0);
            var commandAssignment   = namespaceAssignment.definitions(0).commandDefinition();

            Assert.Collection(commandAssignment.fieldDefinition().Select(a => a.fieldPropertyType()),
                              // first field
                              (f) =>
            {
                Assert.True(f.IsPredefinedType());
            },
                              // second field
                              (f) =>
            {
                Assert.False(f.IsPredefinedType());
            });
        }
Exemple #11
0
        public void Should_return_fields_as_being_required_when_optional_fragment_added(string inputLiteral)
        {
            const string OPTIONAL_LITERAL = "?";
            var          inputCode        = CreateCodeWithFieldDefinitionFromLiteral(inputLiteral, OPTIONAL_LITERAL);
            var          tokenStream      = GetTokenStream(inputCode);
            var          parser           = new CqrsParser(tokenStream);
            var          dictionary       = parser.dictionary();

            var namespaceAssignment = dictionary.GetNamespaceAssignmentContextItem(0, 0);
            var commandAssignment   = namespaceAssignment.definitions(0).commandDefinition();

            Assert.Collection(commandAssignment.fieldDefinition().Select(a => a.fieldPropertyType()),
                              // first field
                              (f) =>
            {
                Assert.True(f.IsOptional());
            },
                              // second field
                              (f) =>
            {
                Assert.True(f.IsOptional());
            });
        }
 public void Should_parse_without_exception(string input)
 {
     var tokenStream = GetTokenStream(input);
     var parser      = new CqrsParser(tokenStream);
     var dictionary  = parser.dictionary();
 }