コード例 #1
0
        public void SupportsParmeterization_DoesNotCacheParameter()
        {
            // Arrange
            int value = 0;

            Expression<Func<SourceWithParams, int>> sourceMember = src => value + 5;
            var config = new MapperConfiguration(cfg => cfg.CreateMap<SourceWithParams, DestWithParams>()
                .ForMember(dest => dest.Value, opt => opt.MapFrom(sourceMember)));
            var mapper = new Mapper(config);

            var source = new[]
            {
                new SourceWithParams()
            }.AsQueryable();

            // Act
            var result1 = source.UseAsDataSource(mapper).For<DestWithParams>(new Dictionary<string, object> { { "value", 10 } }).ToArray();
            var result = source.UseAsDataSource(mapper).For<DestWithParams>(new Dictionary<string, object> { { "value", 15 } }).ToArray();

            // Assert
            result.ShouldNotBeNull();
            result.ShouldNotBeEmpty();
            result.Single().Value.ShouldEqual(20);
        }