public void MapToDest_Null()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Name, d => d.Name)
                    .MapToDest(null);

            Assert.IsNull(r);
        }
示例#2
0
        public void MapToSrce_Null()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Name, d => d.Name)
                    .MapToSrce(null);

            Assert.IsNull(r);
        }
        public void MapToDest_CollNull()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Addresses, d => d.Addresses)
                    .MapToDest(new PersonA());

            Assert.IsNotNull(r);
            Assert.IsNull(r.Addresses);
        }
        public void MapToSrce_StringNull()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Name, d => d.Name)
                    .MapToSrce(new PersonB());

            Assert.IsNotNull(r);
            Assert.IsNull(r.Name);
        }
        public void can_create_using_the_generated_factory_method()
        {
            var sut    = new EntityMapper <PrivateDefaultConstructor>("Entities");
            var record = Substitute.For <IDataRecord>();

            var actual = sut.Create(record);

            actual.Should().NotBeNull();
        }
示例#6
0
        public void MapToSrce_EntityNull_AutoPropMapper()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Address, d => d.AddressX)
                    .MapToSrce(new PersonB());

            Assert.IsNotNull(r);
            Assert.IsNull(r.Address);
        }
示例#7
0
        public void MapToSrce_CollNull()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Addresses, d => d.Addresses)
                    .MapToSrce(new PersonB());

            Assert.IsNotNull(r);
            Assert.IsNull(r.Addresses);
        }
        public void MapToDest_EntityNull_AutoPropMapper()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Address, d => d.AddressX)
                    .MapToDest(new PersonA());

            Assert.IsNotNull(r);
            Assert.IsNull(r.AddressX);
        }
示例#9
0
        public void On(RuleCreated @event, EnvelopeHeaders headers)
        {
            var id = @event.RuleId;

            Rules.SetItem(id, EntityMapper.Create <JsonRuleEntity>(@event, headers, r =>
            {
                r.RuleDef = RuleEventDispatcher.Create(@event);
            }));
        }
示例#10
0
        public void MapToDest_StringNull()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Name, d => d.Name)
                    .MapToDest(new PersonA());

            Assert.IsNotNull(r);
            Assert.IsNull(r.Name);
        }
示例#11
0
        public void On(AppCreated @event, EnvelopeHeaders headers)
        {
            App = EntityMapper.Create <JsonAppEntity>(@event, headers, a =>
            {
                SimpleMapper.Map(@event, a);

                a.LanguagesConfig = LanguagesConfig.Build(Language.EN);
            });
        }
示例#12
0
        public void MapToSrce_NullableZero()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Salary, d => d.Salary)
                    .MapToSrce(new PersonB {
                Salary = 0
            });

            Assert.IsNotNull(r);
            Assert.AreEqual(0, r.Salary);
        }
示例#13
0
        public void On(SchemaCreated @event, EnvelopeHeaders headers)
        {
            var id = @event.SchemaId.Id;

            Schemas = Schemas.SetItem(id, EntityMapper.Create <JsonSchemaEntity>(@event, headers, s =>
            {
                s.SchemaDef = SchemaEventDispatcher.Create(@event, registry);

                SimpleMapper.Map(@event, s);
            }));
        }
示例#14
0
        public void GetByProperty()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Street, d => d.StreetX);

            Assert.IsNotNull(r.GetBySrceProperty(s => s.Street));
            Assert.IsNull(r.GetBySrceProperty(s => s.Name));

            Assert.IsNotNull(r.GetByDestProperty(d => d.StreetX));
            Assert.IsNull(r.GetByDestProperty(d => d.Codes));
        }
示例#15
0
        public void MapToDest_NullableValue()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Salary, d => d.Salary)
                    .MapToDest(new PersonA {
                Salary = 10m
            });

            Assert.IsNotNull(r);
            Assert.AreEqual(10m, r.Salary);
        }
示例#16
0
        public void MapToDest_IntValue()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Age, d => d.Age)
                    .MapToDest(new PersonA {
                Age = 10
            });

            Assert.IsNotNull(r);
            Assert.AreEqual(10, r.Age);
        }
示例#17
0
        public void MapToDest_ArrayNull()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Codes, d => d.Codes)
                    .MapToDest(new PersonA {
                Codes = null
            });

            Assert.IsNotNull(r);
            Assert.IsNull(r.Codes);
        }
示例#18
0
        public void MapToDest_StringValue()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Name, d => d.Name)
                    .MapToDest(new PersonA {
                Name = "AAA"
            });

            Assert.IsNotNull(r);
            Assert.AreEqual("AAA", r.Name);
        }
示例#19
0
        public void MapToDest_NullableNull()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Salary, d => d.Salary)
                    .MapToDest(new PersonA {
                Salary = null
            });

            Assert.IsNotNull(r);
            Assert.AreEqual(0, r.Salary);
        }
示例#20
0
        public void MapToSrce_ArrayNull()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Codes, d => d.Codes)
                    .MapToSrce(new PersonB {
                Codes = null
            });

            Assert.IsNotNull(r);
            Assert.IsNull(r.Codes);
        }
示例#21
0
        public void MapToDest_CollEmpty()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Addresses, d => d.Addresses)
                    .MapToDest(new PersonA {
                Addresses = System.Array.Empty <Address>()
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Addresses);
            Assert.AreEqual(0, r.Addresses.Count);
        }
示例#22
0
        public void MapToDest_CollEmpty()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Addresses, d => d.Addresses)
                    .MapToDest(new PersonA {
                Addresses = new Address[] { }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Addresses);
            Assert.AreEqual(0, r.Addresses.Count);
        }
示例#23
0
        public void MapToSrce_CollEmpty()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Addresses, d => d.Addresses)
                    .MapToSrce(new PersonB {
                Addresses = new List <AddressX>()
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Addresses);
            Assert.AreEqual(0, r.Addresses.Length);
        }
示例#24
0
        public void MapToSrce_ArrayEmpty()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Codes, d => d.Codes)
                    .MapToSrce(new PersonB {
                Codes = new int[0] {
                }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Codes);
            Assert.AreEqual(0, r.Codes.Length);
        }
示例#25
0
        public void MapToDest_ArrayValue()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Codes, d => d.Codes)
                    .MapToDest(new PersonA {
                Codes = new int[] { 1, 2 }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Codes);
            Assert.AreEqual(2, r.Codes.Length);
            Assert.AreEqual(1, r.Codes[0]);
            Assert.AreEqual(2, r.Codes[1]);
        }
示例#26
0
        public void MapToDest_EntityValue_PropMapper3()
        {
            var r = new PersonB {
                AddressX = new AddressX {
                    City = "123", Street = "456"
                }
            };

            EntityMapper.Create <PersonA, PersonB>()
            .HasProperty(s => s.Address, d => d.AddressX, p => p.SetMapper(EntityMapper.Create <Address, AddressX>().HasProperty(sa => sa.Street, da => da.City)))
            .MapToDest(new PersonA(), r);

            Assert.IsNotNull(r);
            Assert.IsNull(r.AddressX);
        }
示例#27
0
        public void MapToSrce_EntityValue_AutoPropMapper()
        {
            var r = EntityMapper.Create <PersonA, PersonB>()
                    .HasProperty(s => s.Address, d => d.AddressX)
                    .MapToSrce(new PersonB {
                AddressX = new AddressX {
                    Street = "AAA", City = "BBB"
                }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Address);
            Assert.AreEqual("AAA", r.Address.Street);
            Assert.AreEqual("BBB", r.Address.City);
        }
示例#28
0
        public void MapToDest_Create_OperationUpdate()
        {
            var r = EntityMapper.Create <TestS, TestD>()
                    .HasProperty(s => s.ChangeLog, d => d.ChangeLog, p => p.SetMapper(ChangeLogMapper.Default))
                    .MapToDest(new TestS {
                ChangeLog = CreateChangeLog()
            }, OperationTypes.Update);

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.ChangeLog);
            Assert.IsNull(r.ChangeLog.CreatedBy);
            Assert.IsNull(r.ChangeLog.CreatedDate);
            Assert.AreEqual("U", r.ChangeLog.UpdatedBy);
            Assert.AreEqual(new DateTime(1980, 01, 01), r.ChangeLog.UpdatedDate);
        }
示例#29
0
        public void MapToDest_EntityValue_AutoPropMapper()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Address, d => d.AddressX)
                    .MapToDest(new PersonA {
                Address = new Address {
                    Street = "AAA", City = "BBB"
                }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.AddressX);
            Assert.AreEqual("AAA", r.AddressX.Street);
            Assert.AreEqual("BBB", r.AddressX.City);
        }
示例#30
0
        public void MapToSrce_EntityValue_PropMapper()
        {
            var r = EntityMapper <PersonA, PersonB> .Create()
                    .HasProperty(s => s.Address, d => d.AddressX, p => p.SetMapper(EntityMapper <Address, AddressX> .Create().HasProperty(sa => sa.Street, da => da.City)))
                    .MapToSrce(new PersonB {
                AddressX = new AddressX {
                    Street = "AAA", City = "BBB"
                }
            });

            Assert.IsNotNull(r);
            Assert.IsNotNull(r.Address);
            Assert.IsNull(r.Address.City);
            Assert.AreEqual("BBB", r.Address.Street);
        }
        public void can_create_using_the_generated_factory_method()
        {
            var sut = new EntityMapper<PrivateDefaultConstructor>("Entities");
            var record = Substitute.For<IDataRecord>();

            var actual = sut.Create(record);

            actual.Should().NotBeNull();
        }