Пример #1
0
 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);
 }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
 public void TestStringMappingNullSet()
 {
     var mapping = new ColumnPropertyMapping<TestUser, string>("UserName", model => model.Name);
     var user = new TestUser();
     Assert.Equal(null, mapping.GetValue(user));
 }
Пример #6
0
 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));
 }
Пример #7
0
 public void InvalidMapping()
 {
     var mapping = new ColumnPropertyMapping<TestUser, DateTime>("CreatedAt", model => model.CreatedAt);
     var user = new TestUser();
     Assert.Throws<MappingException>(() => mapping.SetValue(user, 22));
 }