public void GetterWithInvalidSetterDoesNotGenerateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var returnType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = returnType, MarshalType = returnType }, }; var invalidSetMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { getMethod, invalidSetMethod })); Assert.Empty(propertyBuilder.CreateProperties(new[] { invalidSetMethod, getMethod })); }
public void GetterWithInvalidSetterDoesNotGenerateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var returnType = TypeRegistry.Int32; var getMethod = new CsMethod(null, "GetActive") { ReturnValue = new CsReturnValue(null) { PublicType = returnType, MarshalType = returnType }, }; var invalidSetMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { getMethod, invalidSetMethod })); Assert.Empty(propertyBuilder.CreateProperties(new[] { invalidSetMethod, getMethod })); }
public void GetterMethodReturningStatusCodeWithOutParamGeneratesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = new CsStruct { Name = "SharpGen.Runtime.Result" } } }; getMethod.Add(new CsParameter { PublicType = paramType, Attribute = CsParameterAttribute.Out }); var properties = propertyBuilder.CreateProperties(new[] { getMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.True(prop.IsPropertyParam); Assert.Equal(paramType, prop.PublicType); }
public void MethodWithNameStartingWithSetCreatesProperty() { 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)) } }; setMethod.Add(new CsParameter { PublicType = paramType }); var properties = propertyBuilder.CreateProperties(new[] { setMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.Equal(paramType, prop.PublicType); }
public void MethodWithNameStartingWithSetCreatesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = TypeRegistry.Int32; var setMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; setMethod.Add(new CsParameter(null, null) { PublicType = paramType }); var properties = propertyBuilder.CreateProperties(new[] { setMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.Equal(paramType, prop.PublicType); }
public void MethodWithNameStartingWithSetAndReturningResultGeneratesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsStruct { Name = "SharpGen.Runtime.Result" } } }; setMethod.Add(new CsParameter { PublicType = paramType }); var properties = propertyBuilder.CreateProperties(new[] { setMethod }); Assert.True(properties.ContainsKey("Active"), "Property not created"); var prop = properties["Active"]; Assert.Equal(paramType, prop.PublicType); }
public void DoesNotGeneratePropertyIfGetterAndSetterMismatch() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = TypeRegistry.Int32; var getMethod = new CsMethod(null, "GetActive") { ReturnValue = new CsReturnValue(null) { PublicType = paramType, MarshalType = paramType }, }; var setMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; setMethod.Add(new CsParameter(null, null) { PublicType = TypeRegistry.Int16 }); var props = propertyBuilder.CreateProperties(new[] { getMethod, setMethod }); Assert.Empty(props); }
public void GetterMethodReturningStatusCodeWithOutParamGeneratesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = TypeRegistry.Int32; var getMethod = new CsMethod(null, "GetActive") { ReturnValue = new CsReturnValue(null) { PublicType = new CsStruct(null, "SharpGen.Runtime.Result") } }; getMethod.Add(new CsParameter(null, null) { PublicType = paramType, Attribute = CsParameterAttribute.Out }); var properties = propertyBuilder.CreateProperties(new[] { getMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.True(prop.IsPropertyParam); Assert.Equal(paramType, prop.PublicType); }
public void DoesNotGeneratePropertyIfGetterAndSetterMismatch() { 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 }, }; var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; setMethod.Add(new CsParameter { PublicType = new CsFundamentalType(typeof(short)) }); var props = propertyBuilder.CreateProperties(new[] { getMethod, setMethod }); Assert.Empty(props); }
public void MethodWithNameStartingWithSetAndReturningResultGeneratesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = TypeRegistry.Int32; var setMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = new CsStruct(null, "SharpGen.Runtime.Result") } }; setMethod.Add(new CsParameter(null, null) { PublicType = paramType }); var properties = propertyBuilder.CreateProperties(new[] { setMethod }); Assert.True(properties.ContainsKey("Active"), "Property not created"); var prop = properties["Active"]; Assert.Equal(paramType, prop.PublicType); }
public void DoesNotGeneratePropertyIfOverloaded() { 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 }, }; var getMethodOverload = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = paramType, MarshalType = paramType }, }; var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; setMethod.Add(new CsParameter { PublicType = paramType }); Assert.Empty(propertyBuilder.CreateProperties(new[] { getMethod, setMethod, getMethodOverload })); Assert.Empty(propertyBuilder.CreateProperties(new[] { getMethod, getMethodOverload, setMethod })); }
public void NonPropertyMethodWithNonPropertyNameShouldNotCreateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var setMethod = new CsMethod(null, "MyMethod") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { setMethod })); }
public void InvalidSetterDoesNotCreateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var setMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { setMethod })); }
public void InvalidSetterDoesNotCreateProperty() { 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)) } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { setMethod })); }
public void NonPropertyMethodWithNonPropertyNameShouldNotCreateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var setMethod = new CsMethod { Name = "MyMethod", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; Assert.Empty(propertyBuilder.CreateProperties(new[] { setMethod })); }
public void InvalidGetterDoesNotCreateProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider("SharpGen.Runtime")); var returnType = new CsFundamentalType(typeof(void)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = returnType, MarshalType = returnType }, }; Assert.Empty(propertyBuilder.CreateProperties(new[] { getMethod })); }
public void DoesNotGeneratePropertyIfGetterAndSetterMismatch_ParameterizedGetter() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = new CsStruct { Name = "SharpGen.Runtime.Result" } } }; getMethod.Add(new CsParameter { PublicType = paramType, Attribute = CsParameterAttribute.Out }); var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; setMethod.Add(new CsParameter { PublicType = new CsFundamentalType(typeof(short)) }); var props = propertyBuilder.CreateProperties(new[] { getMethod, setMethod }); Assert.Empty(props); }
public void MethodWithNameStartingWithGetCreatesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var returnType = TypeRegistry.Int32; var getMethod = new CsMethod(null, "GetActive") { ReturnValue = new CsReturnValue(null) { PublicType = returnType, MarshalType = returnType }, }; var properties = propertyBuilder.CreateProperties(new[] { getMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.Equal(returnType, prop.PublicType); }
public void MethodWithNameStartingWithGetCreatesProperty() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var returnType = new CsFundamentalType(typeof(int)); var getMethod = new CsMethod { Name = "GetActive", ReturnValue = new CsReturnValue { PublicType = returnType, MarshalType = returnType }, }; var properties = propertyBuilder.CreateProperties(new[] { getMethod }); Assert.True(properties.ContainsKey("Active")); var prop = properties["Active"]; Assert.Equal(returnType, prop.PublicType); }
public void DoesNotGeneratePropertyIfGetterAndSetterMismatch_ParameterizedGetter() { var propertyBuilder = new PropertyBuilder(new GlobalNamespaceProvider()); var paramType = TypeRegistry.Int32; var getMethod = new CsMethod(null, "GetActive") { ReturnValue = new CsReturnValue(null) { PublicType = new CsStruct(null, "SharpGen.Runtime.Result") } }; getMethod.Add(new CsParameter(null, null) { PublicType = paramType, Attribute = CsParameterAttribute.Out }); var setMethod = new CsMethod(null, "SetActive") { ReturnValue = new CsReturnValue(null) { PublicType = TypeRegistry.Void } }; setMethod.Add(new CsParameter(null, null) { PublicType = TypeRegistry.Int16 }); var props = propertyBuilder.CreateProperties(new[] { getMethod, setMethod }); Assert.Empty(props); }
public void GeneratePropertyIfGetterAndSetterMatch() { 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 }, }; var setMethod = new CsMethod { Name = "SetActive", ReturnValue = new CsReturnValue { PublicType = new CsFundamentalType(typeof(void)) } }; setMethod.Add(new CsParameter { PublicType = paramType }); var props = propertyBuilder.CreateProperties(new[] { getMethod, setMethod }); Assert.Single(props); Assert.NotNull(props["Active"].Getter); Assert.NotNull(props["Active"].Setter); }
public void MethodWithNameStartingWithIsCreatesProperty() { var returnType = TypeRegistry.Int32; CsMethod isMethod = new(Ioc, null, "IsActive") { ReturnValue = new CsReturnValue(Ioc, null) { PublicType = returnType, MarshalType = returnType } }; var properties = propertyBuilder.CreateProperties(new[] { isMethod }); Assert.True(properties.ContainsKey("IsActive")); var prop = properties["IsActive"]; Assert.Equal(returnType, prop.PublicType); }