コード例 #1
0
        public When_mapping_a_data_reader_to_a_dto_and_the_map_does_not_exist()
        {
            var config = new MapperConfiguration(cfg => MapperRegistry.Mappers.Insert(0, new DataReaderMapper()));

            _mapper     = config.CreateMapper();
            _dataReader = new DataBuilder().BuildDataReader();
        }
コード例 #2
0
        public When_mapping_a_data_reader_to_a_dto_with_nullable_enum()
        {
            _config = new MapperConfiguration(cfg =>
            {
                MapperRegistry.Mappers.Insert(0, new DataReaderMapper());

                cfg.CreateMap <IDataReader, DtoWithSingleNullableField>();
            });

            _dataReader = new DataBuilder().BuildDataReaderWithNullableField();
        }
コード例 #3
0
        public When_mapping_a_data_reader_to_a_dto_twice()
        {
            //var mapper = new MapperConfiguration(cfg =>
            //{
            //    MapperRegistry.Mappers.Insert(0, new DataReaderMapper());
            //}).CreateMapper();

            DataReader = new DataBuilder().BuildDataReader();
            Results    = _mapper.Map <IDataReader, IEnumerable <DTOObject> >(DataReader);
            Result     = Results.FirstOrDefault();
        }
コード例 #4
0
        public When_mapping_a_data_reader_to_a_dto_with_nested_dto()
        {
            var config = new MapperConfiguration(cfg =>
            {
                MapperRegistry.Mappers.Insert(0, new DataReaderMapper());
                cfg.CreateMap <IDataReader, DtoWithNestedClass>();
            });


            _dataReader = new DataBuilder().BuildDataReaderWithNestedClass();

            _mapper = config.CreateMapper();
        }
コード例 #5
0
        public When_mapping_a_single_data_record_to_a_dto()
        {
            _config = new MapperConfiguration(cfg =>
            {
                MapperRegistry.Mappers.Insert(0, new DataReaderMapper());
                cfg.CreateMap <IDataRecord, DTOObject>()
                .ForMember(dest => dest.Else, options => options.MapFrom(src => src.GetDateTime(src.GetOrdinal(FieldName.Something))));
            });
            var mapper = _config.CreateMapper();

            _dataRecord = new DataBuilder().BuildDataRecord();
            _result     = mapper.Map <IDataRecord, DTOObject>(_dataRecord);
        }
コード例 #6
0
        public When_mapping_a_data_reader_to_a_dto()
        {
            _config = new MapperConfiguration(cfg =>
            {
                MapperRegistry.Mappers.Insert(0, new DataReaderMapper {
                    YieldReturnEnabled = YieldReturnEnabled
                });
                cfg.CreateMap <IDataReader, DTOObject>()
                .ForMember(dest => dest.Else, options => options.MapFrom(src => src.GetDateTime(10)));
                cfg.CreateMissingTypeMaps = true;
            });

            _mapper = _config.CreateMapper();

            DataReader = new DataBuilder().BuildDataReader();
            Results    = _mapper.Map <IDataReader, IEnumerable <DTOObject> >(DataReader);
            Result     = Results.FirstOrDefault();
        }