public void MetaWrapper_wraps_item_and_cast_identity_both_ways() { var entity = MetaWrapper <Entity, EntityMetaData> .Create(new Entity() { Name = "Test" }); Assert.That(entity is Entity && ((MetaWrapper <Entity, EntityMetaData>)entity is MetaWrapper <Entity, EntityMetaData>)); }
private MetaWrapper <T, MetaData> WrapItem(T item) { MetaWrapper <T, MetaData> meta = item; if (meta == null) { meta = MetaWrapper <T, MetaData> .Create(item); meta.Meta = MetaData.New(); } return(meta); }
public void Meta_wrapper_identity_property_cast_is_same() { var entity = new Entity(); var wrapped = MetaWrapper <Entity, EntityMetaData> .Create(entity, new EntityMetaData() { Id = Guid.NewGuid().ToString() }); MetaWrapper <Entity, EntityMetaData> unwrapped = wrapped; Assert.AreEqual(unwrapped.Meta.Id, MetaWrapper <Entity, EntityMetaData> .GetMetaData(wrapped).Id); }
public void MetaWrapper_casts_item() { var id = Guid.NewGuid().ToString(); var entity = MetaWrapper <Entity, EntityMetaData> .Create(new Entity() { Name = "Test" }, new EntityMetaData() { Id = id }); var meta = (MetaWrapper <Entity, EntityMetaData>)entity; Assert.AreEqual(id, meta.Meta.Id); }