Esempio n. 1
0
        public void OnVisitBuiltInType_called_in_constant_declaration(string dataType, object value)
        {
            var message = $"{dataType} CONST = {value}";
            var expectedPrimitiveType = RosTypeInfo.CreateBuiltIn(dataType);

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitBuiltInType(expectedPrimitiveType));
        }
Esempio n. 2
0
        public void OnVisitRosType_called_in_constant_decalaration_for_external_type()
        {
            var message = $"std_msgs/Bool CONST = True";
            var expectedTypeDescriptor = RosTypeInfo.CreateRosType("std_msgs", "Bool");

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitRosType(expectedTypeDescriptor));
        }
Esempio n. 3
0
        public void OnVisitBuiltInType_called_infield_declaration(string dataType)
        {
            var message             = $"{dataType} fieldName";
            var expectedBuiltInType = RosTypeInfo.CreateBuiltIn(dataType);;

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitBuiltInType(expectedBuiltInType));
        }
Esempio n. 4
0
        public void Empty_comment_returns_empty_string()
        {
            string expectedComment = string.Empty;
            var    message         = $"MyType fieldName        #";

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitComment(expectedComment));
        }
Esempio n. 5
0
        public void Comment_returns_comment_without_leading_and_trailing_whitespaces()
        {
            const string expectedComment = "This is my Comment";
            var          message         = $"MyType fieldName        #  \t{expectedComment}  \t";

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitComment(expectedComment));
        }
Esempio n. 6
0
        public void OnVisitIdentifier_called_in_const_declaration()
        {
            var expectedIdentifier = "CONST_NAME";
            var message            = $"bool {expectedIdentifier} = True";

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitIdentifier(expectedIdentifier));
        }
Esempio n. 7
0
        public void OnVisitRosType_called_in_field_decalaration_for_header_type()
        {
            var message = $"Header fieldName";
            var expectedTypeDescriptor = RosTypeInfo.CreateRosType("std_msgs", "Header");

            var messageParser = ParserHelper.CreateParserForMessage(message);
            var context       = messageParser.ros_message();

            var mock    = new Mock <IRosMessageVisitorListener>();
            var visitor = new RosMessageVisitor(mock.Object);

            visitor.Visit(context);

            mock.Verify(x => x.OnVisitRosType(expectedTypeDescriptor));
        }