コード例 #1
0
        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 CreatePropertyBag_ClassWithMultidimensionalGeneric_GeneratesPropertyBag()
        {
            var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <ClassWithMultidimensionalGeneric>();
            var container   = new ClassWithMultidimensionalGeneric();

            Assert.That(propertyBag.GetProperties(ref container).Count(), Is.EqualTo(2));
        }
コード例 #3
0
        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);
        }
コード例 #5
0
        public void ReflectedPropertyBagGenerator_UnmanagedProperty_Char()
        {
            var propertyBag   = new ReflectedPropertyBagProvider().Generate <ContainerWithCharField>();
            var container     = default(ContainerWithCharField);
            var changeTracker = default(ChangeTracker);
            var action        = new AssertThatPropertyIsOfType <ContainerWithCharField, UnmanagedProperty <ContainerWithCharField, char> >();

            propertyBag.FindProperty("c", ref container, ref changeTracker, ref action);
        }
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        private static void Initialize()
        {
            var provider = new ReflectedPropertyBagProvider();

            provider.AddGenerator(new CharPropertyGenerator());

            PropertyBagResolver.RegisterProvider(provider);
            PropertyBagResolver.Register(new SerializedObjectViewPropertyBag());

            AssemblyReloadEvents.beforeAssemblyReload += HandleDomainWillUnload;
            EditorApplication.update += HandleUpdate;
            Bridge.EditorApplication.UpdateMainWindowTitleHandler += MainWindowTitleHandler;
        }
        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 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);
        }
コード例 #11
0
        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!");
        }
コード例 #13
0
        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!"));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        public void CreatePropertyBag_ListOfInt_ListPropertyBagIsGenerated()
        {
            var propertyBag = new ReflectedPropertyBagProvider().CreatePropertyBag <List <int> >();

            Assert.That(propertyBag.GetType(), Is.EqualTo(typeof(ListPropertyBag <List <int>, int>)));
        }