public void PropertyValueAccessorGetBooleanTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Boolean");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            const bool value = true;
            var user = new EntityWithProperties { Boolean = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BooleanValue, value);
        }
Beispiel #2
0
        public void PropertyValueAccessorGetBooleanTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Boolean");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const bool   value         = true;
            var          user          = new EntityWithProperties {
                Boolean = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BooleanValue, value);
        }
Beispiel #3
0
        public void PropertyValueAccessorGetInt64EnumTest()
        {
            // Arrange
            PropertyInfo      propertyInfo  = typeof(EntityWithProperties).GetProperty("Int64Enum");
            var               valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const MyInt64Enum value         = MyInt64Enum.A;
            var               user          = new EntityWithProperties {
                Int64Enum = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int64)value, entityProperty.Int64Value);
        }
Beispiel #4
0
        public void PropertyValueAccessorGetStringTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("String");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const string value         = "aabbcc";
            var          user          = new EntityWithProperties {
                String = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.StringValue, value);
        }
Beispiel #5
0
        public void PropertyValueAccessorGetNullableInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt64");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            Int64?       value         = 3;
            var          user          = new EntityWithProperties {
                NullableInt64 = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int64Value, value);
        }
Beispiel #6
0
        public void PropertyValueAccessorGetInt32Test()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Int32");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const Int32  value         = 3;
            var          user          = new EntityWithProperties {
                Int32 = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int32Value, value);
        }
Beispiel #7
0
        public void PropertyValueAccessorGetNullableGuidTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableGuid");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            Guid?        value         = Guid.NewGuid();
            var          user          = new EntityWithProperties {
                NullableGuid = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.GuidValue, value);
        }
Beispiel #8
0
        public void PropertyValueAccessorGetDoubleTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Double");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            const Double value         = 0.3;
            var          user          = new EntityWithProperties {
                Double = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DoubleValue, value);
        }
Beispiel #9
0
        public void PropertyValueAccessorGetNullableDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo   propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableDateTimeOffset");
            var            valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            DateTimeOffset?value         = DateTime.UtcNow;
            var            user          = new EntityWithProperties {
                NullableDateTimeOffset = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DateTimeOffsetValue, value);
        }
Beispiel #10
0
        public void PropertyValueAccessorGetNullableInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("NullableInt32Enum");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            MyInt32Enum? value         = MyInt32Enum.NB;
            var          user          = new EntityWithProperties {
                NullableInt32Enum = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int32?)value, entityProperty.Int32Value);
        }
Beispiel #11
0
        public void PropertyValueAccessorGetBinaryTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("Binary");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            var          value         = new byte[] { 0x11, 0x22, 0x33 };
            var          user          = new EntityWithProperties {
                Binary = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BinaryValue, value);
        }
Beispiel #12
0
        public void PropertyValueAccessorGetDateTimeTest()
        {
            // Arrange
            PropertyInfo propertyInfo  = typeof(EntityWithProperties).GetProperty("DateTime");
            var          valueAccessor = new PropertyValueAccessor <EntityWithProperties>(propertyInfo);
            DateTime     value         = DateTime.UtcNow;
            var          user          = new EntityWithProperties {
                DateTime = value
            };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.NotNull(entityProperty.DateTimeOffsetValue);
            Assert.True(entityProperty.DateTimeOffsetValue.HasValue);
            Assert.Equal(entityProperty.DateTimeOffsetValue.Value.DateTime, value);
        }
        public void AddActualColumnValue(PermissionContext permissionContext)
        {
            if (!permissionContext.HasCurrentUserReadPermission(ActualColumnName))
            {
                RendererTreeBuilder.AddContent("*****");
                return;
            }

            if (specialColumnValues.TryGetValue(ActualColumnName, out var rendererFragmentAdapter))
            {
                var fragment = rendererFragmentAdapter.GetColumnFragment(ActualItem);
                RendererTreeBuilder.AddContent(fragment);
                return;
            }

            var valueFormatter = valueFormatters[ActualColumnName];
            var inputForColumnValueFormatter = valueFormatter.FormatterType == ValueFormatterType.SingleProperty
                ? PropertyValueAccessor.GetValue(ActualItem, ActualColumnName)
                : ActualItem;

            RendererTreeBuilder.AddContent(new MarkupString(
                                               valueFormatter.FormatValue(inputForColumnValueFormatter))
                                           );
        }
        public void PropertyValueAccessorGetInt64EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Int64Enum");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            const MyInt64Enum value = MyInt64Enum.A;
            var user = new EntityWithProperties { Int64Enum = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int64)value, entityProperty.Int64Value);
        }
        public void PropertyValueAccessorGetStringTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("String");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            const string value = "aabbcc";
            var user = new EntityWithProperties { String = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.StringValue, value);
        }
        public void PropertyValueAccessorGetNullableInt64Test()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableInt64");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            Int64? value = 3;
            var user = new EntityWithProperties { NullableInt64 = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int64Value, value);
        }
        public void PropertyValueAccessorGetInt32Test()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Int32");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            const Int32 value = 3;
            var user = new EntityWithProperties { Int32 = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.Int32Value, value);
        }
        public void PropertyValueAccessorGetNullableGuidTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableGuid");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            Guid? value = Guid.NewGuid();
            var user = new EntityWithProperties { NullableGuid = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.GuidValue, value);
        }
        public void PropertyValueAccessorGetDoubleTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Double");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            const Double value = 0.3;
            var user = new EntityWithProperties { Double = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DoubleValue, value);
        }
        public void PropertyValueAccessorGetNullableDateTimeOffsetTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableDateTimeOffset");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            DateTimeOffset? value = DateTime.UtcNow;
            var user = new EntityWithProperties { NullableDateTimeOffset = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.DateTimeOffsetValue, value);
        }
        public void PropertyValueAccessorGetNullableInt32EnumTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("NullableInt32Enum");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            MyInt32Enum? value = MyInt32Enum.NB;
            var user = new EntityWithProperties { NullableInt32Enum = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal((Int32?)value, entityProperty.Int32Value);
        }
        public void PropertyValueAccessorGetBinaryTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("Binary");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            var value = new byte[] {0x11, 0x22, 0x33};
            var user = new EntityWithProperties { Binary = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.Equal(entityProperty.BinaryValue, value);
        }
 public object GetActualItemColumnValue(string columnName)
 => PropertyValueAccessor.GetValue(ActualItem, columnName);
        public void PropertyValueAccessorGetDateTimeTest()
        {
            // Arrange
            PropertyInfo propertyInfo = typeof(EntityWithProperties).GetProperty("DateTime");
            var valueAccessor = new PropertyValueAccessor<EntityWithProperties>(propertyInfo);
            DateTime value = DateTime.UtcNow;
            var user = new EntityWithProperties { DateTime = value };

            // Act
            EntityProperty entityProperty = valueAccessor.GetValue(user);

            // Assert
            Assert.NotNull(entityProperty.DateTimeOffsetValue);
            Assert.True(entityProperty.DateTimeOffsetValue.HasValue);
            Assert.Equal(entityProperty.DateTimeOffsetValue.Value.DateTime, value);
        }