Esempio n. 1
0
        public void SetterVisibilityInternal()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider());

            var paramType = new CsFundamentalType(typeof(int));

            var setMethod = new CsMethod
            {
                Name        = "SetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType = new CsFundamentalType(typeof(void))
                },
                AllowProperty = true
            };

            setMethod.Add(new CsParameter
            {
                PublicType = paramType
            });

            var iface = new CsInterface();

            iface.Add(setMethod);

            var prop = new CsProperty("Active")
            {
                Setter = setMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.Equal(Visibility.Internal, setMethod.Visibility);
        }
Esempio n. 2
0
        public void PropertyNotAttachedWhenSetterAllowPropertyIsFalse()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider());

            var paramType = new CsFundamentalType(typeof(int));

            var setMethod = new CsMethod
            {
                Name        = "SetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType = new CsFundamentalType(typeof(void))
                },
                AllowProperty = false
            };

            setMethod.Add(new CsParameter
            {
                PublicType = paramType
            });

            var iface = new CsInterface();

            iface.Add(setMethod);

            var prop = new CsProperty("Active")
            {
                Setter = setMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.Null(prop.Parent);
        }
Esempio n. 3
0
        public void PersistentGetterGeneratesPersistentProperty()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider());

            var paramType = new CsFundamentalType(typeof(int));

            var getMethod = new CsMethod
            {
                Name        = "GetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType  = paramType,
                    MarshalType = paramType
                },
                AllowProperty = true,
                IsPersistent  = true
            };

            var iface = new CsInterface();

            iface.Add(getMethod);

            var prop = new CsProperty("Active")
            {
                Getter = getMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.True(prop.IsPersistent);
        }
Esempio n. 4
0
        public void PersistentGetterGeneratesPersistentProperty()
        {
            CppMethod cppGetMethod = new("GetActive")
            {
                Rule =
                {
                    Property = true,
                    Persist  = true
                }
            };

            var paramType = TypeRegistry.Int32;

            var getMethod = new CsMethod(cppGetMethod, cppGetMethod.Name)
            {
                ReturnValue = new CsReturnValue(null)
                {
                    PublicType  = paramType,
                    MarshalType = paramType
                }
            };

            var iface = new CsInterface(null, null);

            iface.Add(getMethod);

            var prop = new CsProperty(null, "Active", getMethod, null);

            PropertyBuilder.AttachPropertyToParent(prop);

            Assert.True(prop.IsPersistent);
        }
Esempio n. 5
0
        public void SetterVisibilityInternal()
        {
            CppMethod cppSetMethod = new("SetActive")
            {
                Rule =
                {
                    Property = true
                }
            };

            var paramType = TypeRegistry.Int32;

            var setMethod = new CsMethod(cppSetMethod, cppSetMethod.Name)
            {
                ReturnValue = new CsReturnValue(null)
                {
                    PublicType = TypeRegistry.Void
                }
            };

            setMethod.Add(new CsParameter(null, null)
            {
                PublicType = paramType
            });

            var iface = new CsInterface(null, null);

            iface.Add(setMethod);

            var prop = new CsProperty(null, "Active", null, setMethod);

            PropertyBuilder.AttachPropertyToParent(prop);

            Assert.Equal(Visibility.Internal, setMethod.Visibility);
        }
Esempio n. 6
0
        public void PropertyNotAttachedWhenSetterAllowPropertyIsFalse()
        {
            CppMethod cppSetMethod = new("SetActive")
            {
                Rule =
                {
                    Property = false
                }
            };

            var paramType = TypeRegistry.Int32;

            var setMethod = new CsMethod(cppSetMethod, cppSetMethod.Name)
            {
                ReturnValue = new CsReturnValue(null)
                {
                    PublicType = TypeRegistry.Void
                }
            };

            setMethod.Add(new CsParameter(null, null)
            {
                PublicType = paramType
            });

            var iface = new CsInterface(null, null);

            iface.Add(setMethod);

            var prop = new CsProperty(null, "Active", null, setMethod);

            PropertyBuilder.AttachPropertyToParent(prop);

            Assert.Null(prop.Parent);
        }
Esempio n. 7
0
        public void PropertyAttachedToGetterType()
        {
            var paramType = TypeRegistry.Int32;

            CppMethod cppGetMethod = new("GetActive")
            {
                Rule =
                {
                    Property = true
                }
            };

            var getMethod = new CsMethod(cppGetMethod, cppGetMethod.Name)
            {
                ReturnValue = new CsReturnValue(null)
                {
                    PublicType  = paramType,
                    MarshalType = paramType
                }
            };

            var iface = new CsInterface(null, null);

            iface.Add(getMethod);

            var prop = new CsProperty(null, "Active", getMethod, null);

            PropertyBuilder.AttachPropertyToParent(prop);

            Assert.Equal(iface, prop.Parent);
        }
Esempio n. 8
0
        public void GetterVisibiltyInternal()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime"));

            var paramType = new CsFundamentalType(typeof(int));

            var getMethod = new CsMethod
            {
                Name        = "GetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType  = paramType,
                    MarshalType = paramType
                },
                AllowProperty = true
            };

            var iface = new CsInterface();

            iface.Add(getMethod);

            var prop = new CsProperty("Active")
            {
                Getter = getMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.Equal(Visibility.Internal, getMethod.Visibility);
        }
Esempio n. 9
0
        public void PropertyNotAttachedWhenGetterAllowPropertyIsFalse()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime"));

            var paramType = new CsFundamentalType(typeof(int));

            var getMethod = new CsMethod
            {
                Name        = "GetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType  = paramType,
                    MarshalType = paramType
                },
                AllowProperty = false
            };

            var iface = new CsInterface();

            iface.Add(getMethod);

            var prop = new CsProperty("Active")
            {
                Getter = getMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.Null(prop.Parent);
        }
Esempio n. 10
0
        public void SetOnlyPropertyAttachedToSetterType()
        {
            var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime"));

            var paramType = new CsFundamentalType(typeof(int));

            var setMethod = new CsMethod
            {
                Name        = "SetActive",
                ReturnValue = new CsReturnValue
                {
                    PublicType = new CsFundamentalType(typeof(void))
                },
                AllowProperty = true
            };

            setMethod.Add(new CsParameter
            {
                PublicType = paramType
            });

            var iface = new CsInterface();

            iface.Add(setMethod);

            var prop = new CsProperty("Active")
            {
                Setter = setMethod
            };

            propertyBuilder.AttachPropertyToParent(prop);

            Assert.Equal(iface, prop.Parent);
        }