public void MapToDest_Null() { var r = EntityMapper.Create <PersonA, PersonB>() .HasProperty(s => s.Name, d => d.Name) .MapToDest(null); Assert.IsNull(r); }
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(); }
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); }
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); }
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); })); }
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); }
public void On(AppCreated @event, EnvelopeHeaders headers) { App = EntityMapper.Create <JsonAppEntity>(@event, headers, a => { SimpleMapper.Map(@event, a); a.LanguagesConfig = LanguagesConfig.Build(Language.EN); }); }
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); }
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); })); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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]); }
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); }
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); }
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); }
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); }
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(); }