public void ReflectedPropertyBagGenerator_CSharpProperties() { var propertyBag = new ReflectedPropertyBagProvider().Generate <ContainerWithProperties>(); Assert.That(propertyBag.HasProperty("IntProperty"), Is.True); Assert.That(propertyBag.HasProperty("HiddenInt32Property"), Is.False); }
public void ReflectedPropertyBagGenerator_PrivateFields() { var propertyBag = new ReflectedPropertyBagProvider().Generate <ContainerWithPrivateFields>(); Assert.That(propertyBag.HasProperty("m_Int32Value"), Is.True); Assert.That(propertyBag.HasProperty("m_HiddenInt32Value"), Is.False); }
public void ReflectedPropertyBagGenerator_InternalProperties_AbstractClass() { var propertyBag = new ReflectedPropertyBagProvider().Generate <AbstractClassContainerWithInternalProperties>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(AbstractClassContainerWithInternalProperties.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(AbstractClassContainerWithInternalProperties.FloatPropertyName), Is.True); }
public void ReflectedPropertyBagGenerator_InternalProperties_ImplementedAbstractClass() { var propertyBag = new ReflectedPropertyBagProvider().Generate <ImplementedAbstractClassContainerWithInternalProperties>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(AbstractClassContainerWithInternalProperties.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(AbstractClassContainerWithInternalProperties.FloatPropertyName), Is.True); AssertPropertyValueAndTypeIsEqualTo(propertyBag, AbstractClassContainerWithInternalProperties.FloatPropertyName, 3.1416f); }
public void CreatePropertyBag_ImplementedAbstractClassWithInternalProperties_PropertiesAreGenerated() { var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <ImplementedAbstractClassWithInternalProperties>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(AbstractClassWithInternalProperties.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(AbstractClassWithInternalProperties.FloatPropertyName), Is.True); var container = new ImplementedAbstractClassWithInternalProperties(); Assert.That(propertyBag.GetPropertyValue(ref container, AbstractClassWithInternalProperties.FloatPropertyName), Is.EqualTo(3.1416f)); }
public void ReflectedPropertyBagGenerator_PrivateFields() { var propertyBag = new ReflectedPropertyBagProvider().Generate <ClassContainerWithPrivateFields>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassContainerWithPrivateFields.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(ClassContainerWithPrivateFields.FloatPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassContainerWithPrivateFields.NonMaskedPropertyName), Is.True); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithPrivateFields.FloatPropertyName, 123.456f); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithPrivateFields.NonMaskedPropertyName, 1); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithPrivateFields.BoolPropertyName), Is.False); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithPrivateFields.StringPropertyName), Is.False); }
public void CreatePropertyBag_ClassWithInternalFields_PropertiesAreGenerated() { var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <ClassWithInternalFields>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassWithInternalFields.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithInternalFields.FloatPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithInternalFields.MaskedPropertyName), Is.True); Assert.That(propertyBag.HasProperty(DerivedClassWithInternalFields.BoolPropertyName), Is.False); Assert.That(propertyBag.HasProperty(DerivedClassWithInternalFields.StringPropertyName), Is.False); var container = new ClassWithInternalFields(); Assert.That(propertyBag.GetPropertyValue(ref container, ClassWithInternalFields.FloatPropertyName), Is.EqualTo(123.456f)); Assert.That(propertyBag.GetPropertyValue(ref container, ClassWithInternalFields.MaskedPropertyName), Is.EqualTo(1)); }
public void ReflectedPropertyBagGenerator_InternalFields_DerivedClass() { var propertyBag = new ReflectedPropertyBagProvider().Generate <DerivedClassContainerWithInternalFields>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalFields.IntPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalFields.FloatPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalFields.MaskedPropertyName), Is.True); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalFields.IntPropertyName, 42); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalFields.FloatPropertyName, 123.456f); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalFields.MaskedPropertyName, 2); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithInternalFields.BoolPropertyName), Is.True); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithInternalFields.StringPropertyName), Is.True); AssertPropertyValueAndTypeIsEqualTo(propertyBag, DerivedClassContainerWithInternalFields.BoolPropertyName, true); AssertPropertyValueAndTypeIsEqualTo(propertyBag, DerivedClassContainerWithInternalFields.StringPropertyName, "Hello the World!"); }
public void CreatePropertyBag_DerivedClassWithPrivateProperties_PropertiesAreGenerated() { var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <DerivedClassWithPrivateProperties>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassWithPrivateProperties.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithPrivateProperties.FloatPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithPrivateProperties.NonMaskedPropertyName), Is.True); Assert.That(propertyBag.HasProperty(DerivedClassWithPrivateProperties.BoolPropertyName), Is.False); Assert.That(propertyBag.HasProperty(DerivedClassWithPrivateProperties.StringPropertyName), Is.True); var container = new DerivedClassWithPrivateProperties(); Assert.That(propertyBag.GetPropertyValue(ref container, ClassWithPrivateProperties.FloatPropertyName), Is.EqualTo(123.456f)); Assert.That(propertyBag.GetPropertyValue(ref container, ClassWithPrivateProperties.NonMaskedPropertyName), Is.EqualTo(2)); Assert.That(propertyBag.GetPropertyValue(ref container, DerivedClassWithPrivateProperties.StringPropertyName), Is.EqualTo("Hello the World!")); }
public void ReflectedPropertyBagGenerator_InternalProperties() { var propertyBag = new ReflectedPropertyBagProvider().Generate <ClassContainerWithInternalProperties>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalProperties.IntPropertyName), Is.False); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalProperties.FloatPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalProperties.MaskedPropertyName), Is.True); Assert.That(propertyBag.HasProperty(ClassContainerWithInternalProperties.VirtualPropertyName), Is.True); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalProperties.FloatPropertyName, 123.456f); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalProperties.MaskedPropertyName, 1); AssertPropertyValueAndTypeIsEqualTo(propertyBag, ClassContainerWithInternalProperties.VirtualPropertyName, (short)-12345); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithInternalProperties.BoolPropertyName), Is.False); Assert.That(propertyBag.HasProperty(DerivedClassContainerWithInternalProperties.StringPropertyName), Is.False); }
public void CreatePropertyBag_ClassWithMemberAttributes_PropertiesAreGeneratedCorrectly() { var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <ClassWithMemberAttributes>(); Assert.That(propertyBag, Is.Not.Null); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicFieldWithNoAttributesName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivateFieldWithNoAttributesName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicPropertyWithNoAttributesName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivatePropertyWithNoAttributesName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicFieldWithCreatePropertyAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivateFieldWithCreatePropertyAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicPropertyWithCreatePropertyAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivatePropertyWithCreatePropertyAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicFieldWithSerializeFieldAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivateFieldWithSerializeFieldAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicPropertyWithSerializeFieldAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivatePropertyWithSerializeFieldAttributeName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicFieldWithCreatePropertyAndNonSerializedAttributesName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivateFieldWithCreatePropertyAndNonSerializedAttributesName), Is.True); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PublicFieldWithSerializeFieldAndNonSerializedAttributesName), Is.False); Assert.That(propertyBag.HasProperty(ClassWithMemberAttributes.PrivateFieldWithSerializeFieldAndNonSerializedAttributesName), Is.False); }