public void CreateInstanceFromProperties_TargetTypeDecoratedWithETagAttribute_ETagSetCorrectly() { var genericEntity = new GenericTableEntity { ETag = "tag" }; var entityProperties = new Dictionary<string, EntityProperty>(); entityProperties["Age"] = new EntityProperty( 42 ); genericEntity.ReadEntity( entityProperties, null ); var item = genericEntity.ConvertTo<DecoratedItemWithETag>(); Assert.AreEqual( "tag", item.ETag, "Incorrect ETag" ); }
public void CreateInstanceFromProperties_TargetTypeDecoratedWithTimestampAttribute_TimestampSetCorrectly() { var dt = DateTime.Now; var genericEntity = new GenericTableEntity { Timestamp = dt }; var entityProperties = new Dictionary<string, EntityProperty>(); entityProperties["Age"] = new EntityProperty( 42 ); genericEntity.ReadEntity( entityProperties, null ); var item = genericEntity.ConvertTo<DecoratedItemWithTimestamp>(); Assert.AreEqual( dt, item.Timestamp, "Incorrect Timestamp" ); }
public void CreateInstanceFromProperties_TargetTypeDecoratedWithRowAndPartitionKeyAttributes_RowAndPartitionKeySetCorrectly() { var genericEntity = new GenericTableEntity { PartitionKey = "foo", RowKey = "bar" }; var entityProperties = new Dictionary<string, EntityProperty>(); entityProperties["Age"] = new EntityProperty( 42 ); genericEntity.ReadEntity( entityProperties, null ); var item = genericEntity.ConvertTo<DecoratedItem>(); Assert.AreEqual( "foo", item.Id, "Incorrect partition key" ); Assert.AreEqual( "bar", item.Name, "Incorrect row key" ); }