Exemple #1
0
        public void MappingFactory_KnownSourceAndTargetType_Create_ReturnsSameInstance()
        {
            var factory = new MappingFactory(typeof(UserToUserViewMap).Assembly);
            var mapper1 = factory.Create <User, UserView>();

            var mapper2 = factory.Create <User, UserView>();

            mapper1.ShouldBe(mapper2);
        }
Exemple #2
0
        public void MappingFactory_KnownSourceAndTargetType_Create_ReturnsInstance()
        {
            var factory = new MappingFactory(typeof(UserToUserViewMap).Assembly);

            var mapper = factory.Create <User, UserView>();

            mapper.ShouldNotBeNull();
        }
Exemple #3
0
        public void MappingFactory_UnknownSourceAndTargetType_Create_ReturnsNull()
        {
            var factory = new MappingFactory(typeof(MapBase).Assembly);

            var mapper = factory.Create <User, UserView>();

            mapper.ShouldBeNull();
        }
Exemple #4
0
        public void MappingFactory_ForAllMappings_GetAll_ReturnsSameInstanceAsCreate()
        {
            var factory  = new MappingFactory(typeof(UserToUserViewMap).Assembly);
            var mapping1 = factory.Create <User, UserView>();

            var mappings = factory.GetAll();

            var mapping2 = mappings.First();

            mapping2.ShouldBe(mapping1);
        }
Exemple #5
0
        public override TTarget Convert(TSource source)
        {
            var mapper = MappingFactory.Create <TSource, TTarget>();

            return(mapper?.Map(source));
        }