public void UnMap_WhenRemovesAnExistingMapping_ShouldRemoveMappingFromProperties() { var target = new IntEntityClassMapper(); target.Map(p => p.String); Assert.True(target.MappingExists(x => x.String)); target.UnMap(p => p.String); Assert.False(target.MappingExists(x => x.String)); }
public void Key_WhenMapKeys_ShouldBeInKeys() { var sut = new IntEntityClassMapper(); sut.Key(x => x.Id); var result = sut.GetKeyMapByName(nameof(IntEntity.Id)); Assert.NotNull(result); }
public void Key_WhenKeyIsAutoGenerated_ShouldBeIgnoredAndReadOnly() { var sut = new IntEntityClassMapper(); sut.Key(x => x.Id).GeneratedBy.AutoGenerated(); var result = sut.GetKeyMapByName(nameof(IntEntity.Id)); Assert.NotNull(result); result.AssertPropertyMap(nameof(IntEntity.Id), true, true); }
public void EntityType_WhenTableAndSchemaAreSet_ShouldMatchWithPropertiesValues() { const string schemaName = "schema_name"; const string tableName = "table_name"; var sut = new IntEntityClassMapper(); sut.Schema(schemaName); sut.Table(tableName); Assert.Equal(sut.TableName, tableName); Assert.Equal(sut.SchemaName, schemaName); }
public void Key_WhenKColumnNameIsChanged_ShouldHaveNewColumnName() { const string columnName = "new_name"; var sut = new IntEntityClassMapper(); sut.Key(x => x.Id).Column(columnName); var result = sut.GetKeyMapByName(nameof(IntEntity.Id)); Assert.NotNull(result); result.AssertPropertyMap(columnName, true, true); }
public void EntityType_WhenCreatingNewMapper_ShouldEntityTypeMatch() { var sut = new IntEntityClassMapper(); Assert.Equal(typeof(IntEntity), sut.EntityType); }
public void UnMap_WhenUnMapNonExistenceProperty_ShouldThrowException() { var target = new IntEntityClassMapper(); Assert.Throws <PropertyMapNotFoundException>(() => target.UnMap(p => p.String)); }