public void Convert_IfOtherPropertyIsReadOnly_PopulatesOtherProperty()
        {
            // Arrange
            int?expectedOtherProperty = 123;
            IConverter <PocoWithReadOnlyOtherProperty, ITableEntity> product =
                CreateProductUnderTest <PocoWithReadOnlyOtherProperty>();
            PocoWithReadOnlyOtherProperty input = new PocoWithReadOnlyOtherProperty
            {
                WriteOtherProperty = expectedOtherProperty
            };

            // Act
            ITableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            IDictionary <string, EntityProperty> properties = actual.WriteEntity(operationContext: null);

            Assert.NotNull(properties);
            Assert.True(properties.ContainsKey("OtherProperty"));
            EntityProperty otherProperty = properties["OtherProperty"];

            Assert.NotNull(otherProperty);
            Assert.Equal(EdmType.Int32, otherProperty.PropertyType);
            Assert.Equal(expectedOtherProperty, otherProperty.Int32Value);
        }
        public void Convert_IfOtherPropertyIsReadOnly_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <TableEntity, PocoWithReadOnlyOtherProperty> product =
                CreateProductUnderTest <PocoWithReadOnlyOtherProperty>();
            TableEntity entity = new TableEntity
            {
                PartitionKey      = expectedPartitionKey,
                ["OtherProperty"] = 456
            };
            // Act
            PocoWithReadOnlyOtherProperty actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
        }
        public void Convert_IfOtherPropertyIsReadOnly_PopulatesOtherProperty()
        {
            // Arrange
            int?expectedOtherProperty = 123;
            IConverter <PocoWithReadOnlyOtherProperty, TableEntity> product =
                CreateProductUnderTest <PocoWithReadOnlyOtherProperty>();
            PocoWithReadOnlyOtherProperty input = new PocoWithReadOnlyOtherProperty
            {
                WriteOtherProperty = expectedOtherProperty
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.NotNull(actual);
            Assert.True(actual.ContainsKey("OtherProperty"));
            var otherProperty = actual["OtherProperty"];

            Assert.NotNull(otherProperty);
            Assert.AreEqual(expectedOtherProperty, otherProperty);
        }
Example #4
0
        public void Convert_IfOtherPropertyIsReadOnly_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <ITableEntity, PocoWithReadOnlyOtherProperty> product =
                CreateProductUnderTest <PocoWithReadOnlyOtherProperty>();
            DynamicTableEntity entity = new DynamicTableEntity
            {
                PartitionKey = expectedPartitionKey,
                Properties   = new Dictionary <string, EntityProperty>
                {
                    { "OtherProperty", new EntityProperty(456) }
                }
            };

            // Act
            PocoWithReadOnlyOtherProperty actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.Same(expectedPartitionKey, actual.PartitionKey);
        }