Esempio n. 1
0
        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>));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }