Ejemplo n.º 1
0
        public void ColumnGetter()
        {
            var type             = typeof(EntityWithAllAttributes);
            var entityDefinition = _entityDefinitionContainer.Get(type);
            var idColumn         = entityDefinition.IdColumn;
            var entity           = new EntityWithAllAttributes();

            Assert.Equal(0L, idColumn.Getter.Invoke(entity));
            entity.Id = 1L;
            Assert.Equal(1L, idColumn.Getter.Invoke(entity));
            entity.Id = 0L;
            Assert.Equal(0L, idColumn.Getter.Invoke(entity));

            var nameColumn = entityDefinition.Columns.Single(it => string.Equals(it.Property.Name, nameof(EntityWithAllAttributes.Name)));

            Assert.Null(nameColumn.Getter.Invoke(entity));
            entity.Name = "test";
            Assert.Equal("test", nameColumn.Getter.Invoke(entity));
            entity.Name = null;
            Assert.Null(nameColumn.Getter.Invoke(entity));
        }
Ejemplo n.º 2
0
        public void ColumnSetter()
        {
            var type             = typeof(EntityWithAllAttributes);
            var entityDefinition = _entityDefinitionContainer.Get(type);
            var idColumn         = entityDefinition.IdColumn;
            var entity           = new EntityWithAllAttributes();

            Assert.Equal(0L, entity.Id);
            idColumn.Setter.Invoke(entity, 1L);
            Assert.Equal(1L, entity.Id);
            idColumn.Setter.Invoke(entity, 0L);
            Assert.Equal(0L, entity.Id);

            var nameColumn = entityDefinition.Columns.Single(it => string.Equals(it.Property.Name, nameof(EntityWithAllAttributes.Name)));

            Assert.Null(entity.Name);
            nameColumn.Setter.Invoke(entity, "test");
            Assert.Equal("test", entity.Name);
            nameColumn.Setter.Invoke(entity, null);
            Assert.Null(entity.Name);
        }