Ejemplo n.º 1
0
        public void MapNullInstance_Test()
        {
            // arrange
            StubDb dto1 = null;
            var    sut  = new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create());

            // act
            var result = sut.Map <StubPerson>(dto1);

            // assert
            result.ShouldBeNull();
        }
Ejemplo n.º 2
0
        public void MapInstance_Test()
        {
            // arrange
            var dto1 = new StubDb {
                Identifier = "111"
            };
            var sut = new AutoMapperEntityMapper(StubEntityMapperConfiguration.Create());

            // act
            var result = sut.Map <StubPerson>(dto1);

            // assert
            result.Id.ShouldBe("111");
        }
        public void Map_FieldValueListWithSameReferenceParent_ReferenceMaintainedInMapping()
        {
            var target = new AutoMapperEntityMapper(new Mapper(MappingConfigurationProvider));

            var fieldRow = new FieldRow {
                FieldId = 234, Name = "Field1", Description = "The first field"
            };
            var domainIdentity1Row = new DomainIdentityRow {
                DomainIdentityId = 134, FirstName = "Tom", LastName = "Bomb", UniqueIdentifier = "*****@*****.**"
            };
            var domainIdentity2Row = new DomainIdentityRow {
                DomainIdentityId = 765, FirstName = "Tim", LastName = "Bo", UniqueIdentifier = "*****@*****.**"
            };

            var fieldValueRows = new List <FieldValueRow>
            {
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93453,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity1Row,
                    LastModifiedByDomainIdentifierId = domainIdentity1Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93454,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity1Row,
                    LastModifiedByDomainIdentifierId = domainIdentity1Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93455,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93456,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93457,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
            };

            var values = new List <FieldValue>();

            Trace.WriteLine("test");

            foreach (var row in fieldValueRows)
            {
                values.Add(target.Map <FieldValue>(row));
            }

            var firstField = values.First().Field;

            foreach (var value in values)
            {
                Assert.AreSame(firstField, value.Field);
            }
        }