public void Convert_IfOtherPropertyIsWriteOnly_PopulatesOtherProperty()
        {
            // Arrange
            int?expectedOtherProperty = 123;
            IConverter <TableEntity, PocoWithWriteOnlyOtherProperty> product =
                CreateProductUnderTest <PocoWithWriteOnlyOtherProperty>();
            TableEntity entity = new TableEntity
            {
                ["OtherProperty"] = expectedOtherProperty
            };
            // Act
            PocoWithWriteOnlyOtherProperty actual = product.Convert(entity);

            // Assert
            Assert.NotNull(actual);
            Assert.AreEqual(expectedOtherProperty, actual.ReadOtherProperty);
        }
        public void Convert_IfOtherPropertyIsWriteOnly_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <PocoWithWriteOnlyOtherProperty, TableEntity> product =
                CreateProductUnderTest <PocoWithWriteOnlyOtherProperty>();
            PocoWithWriteOnlyOtherProperty input = new PocoWithWriteOnlyOtherProperty
            {
                PartitionKey  = expectedPartitionKey,
                OtherProperty = 456
            };
            // Act
            TableEntity actual = product.Convert(input);

            // Assert
            Assert.NotNull(actual);
            Assert.NotNull(actual);
            Assert.False(actual.ContainsKey("OtherProperty"));
            Assert.AreSame(expectedPartitionKey, actual.PartitionKey);
        }
Beispiel #3
0
        public void Convert_IfOtherPropertyIsWriteOnly_PopulatesOtherProperty()
        {
            // Arrange
            int?expectedOtherProperty = 123;
            IConverter <ITableEntity, PocoWithWriteOnlyOtherProperty> product =
                CreateProductUnderTest <PocoWithWriteOnlyOtherProperty>();
            DynamicTableEntity entity = new DynamicTableEntity
            {
                Properties = new Dictionary <string, EntityProperty>
                {
                    { "OtherProperty", new EntityProperty(expectedOtherProperty) }
                }
            };

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

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(expectedOtherProperty, actual.ReadOtherProperty);
        }
        public void Convert_IfOtherPropertyIsWriteOnly_Ignores()
        {
            // Arrange
            const string expectedPartitionKey = "PK";
            IConverter <PocoWithWriteOnlyOtherProperty, ITableEntity> product =
                CreateProductUnderTest <PocoWithWriteOnlyOtherProperty>();
            PocoWithWriteOnlyOtherProperty input = new PocoWithWriteOnlyOtherProperty
            {
                PartitionKey  = expectedPartitionKey,
                OtherProperty = 456
            };

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

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

            Assert.NotNull(properties);
            Assert.False(properties.ContainsKey("OtherProperty"));
            Assert.Same(expectedPartitionKey, actual.PartitionKey);
        }