Exemple #1
0
        private static ITableEntity Copy(ITableEntity item)
        {
            var props = TableEntityValueBinder.DeepClone(item.WriteEntity(null));
            DynamicTableEntity copy = new DynamicTableEntity(item.PartitionKey, item.RowKey, item.ETag, props);

            return(copy);
        }
Exemple #2
0
 public PocoEntityValueBinder(TableEntityContext entityContext, string eTag, TElement value)
 {
     _entityContext      = entityContext;
     _eTag               = eTag;
     _value              = value;
     _originalProperties =
         TableEntityValueBinder.DeepClone(_converter.Convert(value).WriteEntity(operationContext: null));
 }
        public void HasChanged_ReturnsFalse_IfValueHasNotChanged()
        {
            // Arrange
            TableEntityContext entityContext = new TableEntityContext();
            DynamicTableEntity value = new DynamicTableEntity
            {
                PartitionKey = "PK",
                RowKey = "RK",
                Properties = new Dictionary<string, EntityProperty> { { "Item", new EntityProperty("Foo") } }
            };
            Type valueType = typeof(DynamicTableEntity);
            TableEntityValueBinder product = new TableEntityValueBinder(entityContext, value, valueType);

            // Act
            bool hasChanged = product.HasChanged;

            // Assert
            Assert.False(hasChanged);
        }
Exemple #4
0
 private bool HasChanges(ITableEntity current)
 {
     return(TableEntityValueBinder.HasChanges(_originalProperties, current.WriteEntity(operationContext: null)));
 }
        public void HasChanged_ReturnsTrue_IfMutuableValueHasBeenMutated()
        {
            // Arrange
            TableEntityContext entityContext = new TableEntityContext();
            byte[] bytes = new byte[] { 0x12 };
            DynamicTableEntity value = new DynamicTableEntity
            {
                PartitionKey = "PK",
                RowKey = "RK",
                Properties = new Dictionary<string, EntityProperty> { { "Item", new EntityProperty(bytes) } }
            };
            Type valueType = typeof(DynamicTableEntity);
            TableEntityValueBinder product = new TableEntityValueBinder(entityContext, value, valueType);

            bytes[0] = 0xFE;

            // Act
            bool hasChanged = product.HasChanged;

            // Assert
            Assert.True(hasChanged);
        }