public void TestStringMappingSet() { var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name); var user = new TestUser(); mapping.SetValue(user, "Pelle"); Assert.Equal("Pelle", user.Name); }
public void StringToDateConversion() { var mapping = new ColumnPropertyMapping<TestUser, DateTime>("CreatedAt", model => model.CreatedAt, ctx => ctx.ToDateTime()); var user = new TestUser(); var context = new ValueContext<TestUser> { ColumnValue = "2009-11-01", Entity = user }; var value = mapping.ConvertValue(context); Assert.Equal(new DateTime(2009,11,01), value); }
public void AutoToStringConversion() { var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name); var user = new TestUser(); var ctx = new ValueContext<TestUser> {ColumnValue = 22, Entity = user}; var value = mapping.ConvertValue(ctx); Assert.Equal("22", value); mapping.SetValue(user, value); }
private void AddRow(ColumnPropertyMapping m) { Entity entity = GetSelectedEntity(); ITable table = GetSelectedTable(); var leftCT = CreatePropertyComboBox(entity, m.Property); var rightCT = CreateColumnComboBox(table, m.Column); var removeButton = CreateRemoveButton(); gridControl.AddRow(leftCT, rightCT, removeButton); }
public void TestStringMappingNullSet() { var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name); var user = new TestUser(); Assert.Equal(null, mapping.GetValue(user)); }
public void TestStringMappingGet() { var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name); var user = new TestUser {Name = "Arne"}; Assert.Equal("Arne", mapping.GetValue(user)); }
public void InvalidMapping() { var mapping = new ColumnPropertyMapping<TestUser, DateTime>("CreatedAt", model => model.CreatedAt); var user = new TestUser(); Assert.Throws<MappingException>(() => mapping.SetValue(user, 22)); }