示例#1
0
        public void MappingFailsWithNullTargetObject()
        {
            var mappingSet = new CustomMappingSet();
            var context    = new MappingContext {
                Source = ""
            };

            Assert.False(mappingSet.Run(context));
        }
示例#2
0
        public void MappingRunsWhenSourceObjectHasNoPropertyName()
        {
            var source  = new SourceInvalid1();
            var target  = new TargetValid();
            var context = new MappingContext {
                Source = source, Target = target
            };
            var mappingSet = new CustomMappingSet();

            Assert.True(mappingSet.Run(context));
            Assert.Equal(1, context.RunFail.Count);
            Assert.Equal("Mapping1", context.RunFail.First().Identifier);
            Assert.Equal(1, context.RunSuccess.Count);
            Assert.Equal("Mapping2", context.RunSuccess.First().Identifier);
            Assert.Equal(DateTime.Now.Date, target.LastUpdated);
        }
示例#3
0
        public void MappingRunsWhenTargetObjectHasNoPropertyDescription()
        {
            var source = new SourceValid {
                Name = "aaa"
            };
            var target  = new TargetInvalid1();
            var context = new MappingContext {
                Source = source, Target = target
            };
            var mappingSet = new CustomMappingSet();

            Assert.True(mappingSet.Run(context));
            Assert.Equal(1, context.RunSuccess.Count);
            Assert.Equal("Mapping1", context.RunSuccess.First().Identifier);
            Assert.Equal(source.Name, target.Description);
            Assert.Equal(1, context.RunFail.Count);
            Assert.Equal("Mapping2", context.RunFail.First().Identifier);
        }
示例#4
0
        public void MappingRunsProperly()
        {
            var source = new SourceValid {
                Name = "aaa"
            };
            var target  = new TargetValid();
            var context = new MappingContext {
                Source = source, Target = target
            };
            var mappingSet = new CustomMappingSet();

            Assert.True(mappingSet.Run(context));
            Assert.Equal(2, context.RunSuccess.Count);
            Assert.Contains("Mapping1", context.RunSuccess.Select(m => m.Identifier));
            Assert.Contains("Mapping2", context.RunSuccess.Select(m => m.Identifier));
            Assert.Equal(source.Name, target.Description);
            Assert.Equal(DateTime.Now.Date, target.LastUpdated);
        }
示例#5
0
        public void MappingFailsWithNullMappingContext()
        {
            var mappingSet = new CustomMappingSet();

            Assert.False(mappingSet.Run(null));
        }