Exemplo n.º 1
0
        public void GetPropertiesToActivate_IncludesNonPublic()
        {
            // Arrange
            var instance = new TestClassWithPropertyVisiblity();
            var typeInfo = instance.GetType().GetTypeInfo();

            // Act
            var propertiesToActivate = PropertyActivator <int> .GetPropertiesToActivate(
                typeof(TestClassWithPropertyVisiblity),
                typeof(TestActivateAttribute),
                (propertyInfo) => new PropertyActivator <int>(propertyInfo, valueAccessor : (val) => val),
                includeNonPublic : true);

            // Assert
            Assert.Equal(5, propertiesToActivate.Length);
        }
Exemplo n.º 2
0
        public void GetPropertiesToActivate_ExcludesNonPublic()
        {
            // Arrange
            var instance             = new TestClassWithPropertyVisiblity();
            var typeInfo             = instance.GetType().GetTypeInfo();
            var expectedPropertyInfo = typeInfo.GetDeclaredProperty("Public");

            // Act
            var propertiesToActivate = PropertyActivator <int> .GetPropertiesToActivate(
                typeof(TestClassWithPropertyVisiblity),
                typeof(TestActivateAttribute),
                (propertyInfo) => new PropertyActivator <int>(propertyInfo, valueAccessor : (val) => val));

            // Assert
            Assert.Equal(1, propertiesToActivate.Length);
            Assert.Single(propertiesToActivate, p => p.PropertyInfo == expectedPropertyInfo);
        }
Exemplo n.º 3
0
        public void GetPropertiesToActivate_ExcludesNonPublic()
        {
            // Arrange
            var instance = new TestClassWithPropertyVisiblity();
            var typeInfo = instance.GetType().GetTypeInfo();
            var expectedPropertyInfo = typeInfo.GetDeclaredProperty("Public");

            // Act
            var propertiesToActivate = PropertyActivator<int>.GetPropertiesToActivate(
                typeof(TestClassWithPropertyVisiblity),
                typeof(TestActivateAttribute),
                (propertyInfo) => new PropertyActivator<int>(propertyInfo, valueAccessor: (val) => val));

            // Assert
            Assert.Equal(1, propertiesToActivate.Length);
            Assert.Single(propertiesToActivate, p => p.PropertyInfo == expectedPropertyInfo);
        }
Exemplo n.º 4
0
        public void GetPropertiesToActivate_IncludesNonPublic()
        {
            // Arrange
            var instance = new TestClassWithPropertyVisiblity();
            var typeInfo = instance.GetType().GetTypeInfo();

            // Act
            var propertiesToActivate = PropertyActivator<int>.GetPropertiesToActivate(
                typeof(TestClassWithPropertyVisiblity),
                typeof(TestActivateAttribute),
                (propertyInfo) => new PropertyActivator<int>(propertyInfo, valueAccessor: (val) => val),
                includeNonPublic: true);

            // Assert
            Assert.Equal(5, propertiesToActivate.Length);
        }