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

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

            Assert.IsNull(r);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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();
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 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);
            }));
        }
Esempio n. 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);
        }
Esempio n. 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);
            });
        }
Esempio n. 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);
        }
Esempio n. 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);
            }));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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]);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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();
        }