Example #1
0
        public void Array_is_striped_from_type_name(string rosType, string expectedPackageName, string expectedTypeName)
        {
            var type = RosType.Parse(rosType);

            type.Should().NotBeNull();
            type.IsArray.Should().BeTrue();
            type.PackageName.Should().Be(expectedPackageName);
            type.TypeName.Should().Be(expectedTypeName);
        }
Example #2
0
        public void Tostring_returns_array_type_with_specifier(string rosType, string rosTypeWithoutArray)
        {
            var type = RosType.Parse(rosType);

            type.Should().NotBeNull();
            type.ToString().Should().Be(rosType);

            type.ToString("F").Should().Be(rosType);
            type.ToString("T").Should().Be(rosTypeWithoutArray);
        }
Example #3
0
        public void Can_parse_arrays(string rosType, bool isFixedSizeArray, int arraySize)
        {
            var type = RosType.Parse(rosType);

            type.Should().NotBeNull();
            type.IsArray.Should().BeTrue();
            type.IsFixedSizeArray.Should().Be(isFixedSizeArray);
            type.IsDynamicArray.Should().Be(!isFixedSizeArray);
            type.ArraySize.Should().Be(arraySize);
            type.ToString().Should().Be(rosType);
        }
Example #4
0
        public void Can_parse_built_in_types(string rosType)
        {
            var type = RosType.Parse(rosType);

            type.Should().NotBeNull();
            type.ToString().Should().Be(rosType);
            type.TypeName.Should().Be(rosType.TrimEnd('[', ']'));
            type.PackageName.Should().BeNull();
            type.IsBuiltIn.Should().BeTrue();
            type.IsFullQualified.Should().BeTrue();
        }
Example #5
0
        public void Header_can_be_defined_in_other_package_as_well()
        {
            var type = RosType.Parse("my_msgs/Header");

            type.Should().NotBeNull();
            type.IsHeaderType.Should().BeFalse();
            type.PackageName.Should().Be("my_msgs");
            type.TypeName.Should().Be("Header");
            type.ToString().Should().Be("my_msgs/Header");
            type.ToString("F").Should().Be("my_msgs/Header");
            type.ToString("T").Should().Be("my_msgs/Header");
            type.IsBuiltIn.Should().BeFalse();
        }
Example #6
0
        public void Can_parse_header(string headerType)
        {
            const string HeaderTypeName = "std_msgs/Header";

            var type = RosType.Parse(headerType);

            type.Should().NotBeNull();
            type.IsHeaderType.Should().BeTrue();
            type.PackageName.Should().Be("std_msgs");
            type.TypeName.Should().Be("Header");
            type.ToString().Should().Be(HeaderTypeName);
            type.ToString("F").Should().Be(HeaderTypeName);
            type.ToString("T").Should().Be(HeaderTypeName);
            type.IsBuiltIn.Should().BeFalse();
            type.IsArray.Should().BeFalse();
        }
Example #7
0
        void Can_parse_not_packaged_type_name()
        {
            const string TypeName = "FooMsg";

            var type = RosType.Parse(TypeName);

            type.Should().NotBeNull();
            type.IsArray.Should().BeFalse();
            type.IsFixedSizeArray.Should().BeFalse();
            type.IsDynamicArray.Should().BeFalse();
            type.ArraySize.Should().Be(0);
            type.PackageName.Should().BeNull();
            type.TypeName.Should().Be("FooMsg");
            type.IsBuiltIn.Should().BeFalse();
            type.IsFullQualified.Should().BeFalse();
            type.IsHeaderType.Should().BeFalse();
            type.ToString().Should().Be(TypeName);
            type.ToString("T").Should().Be(TypeName);
            type.ToString("F").Should().Be(TypeName);
        }
Example #8
0
        public void CanWriteAndReadBuiltInTypes2(string rosType, object writeValue, object expectedValue)
        {
            var primitiveRosType = RosType.Parse(rosType);

            primitiveRosType.IsBuiltIn.Should().BeTrue();
            primitiveRosType.IsArray.Should().BeFalse();

            using (var s = new MemoryStream())
            {
                var writer = new RosBinaryWriter(s);
                var reader = new RosBinaryReader(s);

                writer.WriteBuiltInType(primitiveRosType, writeValue);

                s.Position = 0;

                var readValue = reader.ReadBuiltInType(primitiveRosType, expectedValue.GetType());

                readValue.Should().BeEquivalentTo(expectedValue);
                readValue.GetType().Should().Be(expectedValue.GetType());
            }
        }
Example #9
0
        public void Invalid_name_thrpws_exception(string name)
        {
            Action parse = () => RosType.Parse(name);

            parse.Should().Throw <FormatException>();
        }
 private IntegrosActionTypeInfo(Type type)
 {
     Type    = type;
     RosType = RosType.Parse("integros_msgs/" + type.Name);
 }