public void validation_of_correct_values_returns_true_for_X0()
        {
            var validator = _factory.Build("total~*.0");

            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=0")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=1")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=2")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=3")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=5")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=17")));
            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("total=100")));
        }
Example #2
0
        public void decimal_validator_X0_is_build()
        {
            var validator = _factory.Build("total~*.0");

            Assert.IsNotNull(validator);
            Assert.IsInstanceOfType(validator, typeof(DecimalValueMappingValidator));
        }
Example #3
0
        /// <summary>
        /// Constructs and returns a <see cref="MarketMappingCacheItem"/> from the provided DTO
        /// </summary>
        /// <param name="dto">The <see cref="MarketMappingDTO"/> containing mapping data</param>
        /// <param name="factory">The <see cref="IMappingValidatorFactory"/> used to construct mapping validator</param>
        /// <param name="culture">A <see cref="CultureInfo"/> </param>
        /// <returns>The constructed <see cref="MarketMappingCacheItem"/></returns>
        /// <exception cref="InvalidOperationException">The format of <see cref="MarketMappingDTO.ValidFor"/> is not correct</exception>
        public static MarketMappingCacheItem Build(MarketMappingDTO dto, IMappingValidatorFactory factory, CultureInfo culture)
        {
            Guard.Argument(dto, nameof(dto)).NotNull();
            Guard.Argument(factory, nameof(factory)).NotNull();

            return(string.IsNullOrEmpty(dto.ValidFor)
                ? new MarketMappingCacheItem(dto, null, culture)
                : new MarketMappingCacheItem(dto, factory.Build(dto.ValidFor), culture));
        }
        /// <summary>
        /// Constructs and returns a <see cref="MarketMappingCacheItem"/> from the provided DTO
        /// </summary>
        /// <param name="dto">The <see cref="MarketMappingDTO"/> containing mapping data</param>
        /// <param name="factory">The <see cref="IMappingValidatorFactory"/> used to construct mapping validator</param>
        /// <param name="culture">A <see cref="CultureInfo"/> </param>
        /// <returns>The constructed <see cref="MarketMappingCacheItem"/></returns>
        /// <exception cref="InvalidOperationException">The format of <see cref="MarketMappingDTO.ValidFor"/> is not correct</exception>
        public static MarketMappingCacheItem Build(MarketMappingDTO dto, IMappingValidatorFactory factory, CultureInfo culture)
        {
            Contract.Requires(dto != null);
            Contract.Requires(factory != null);

            return(string.IsNullOrEmpty(dto.ValidFor)
                ? new MarketMappingCacheItem(dto, null, culture)
                : new MarketMappingCacheItem(dto, factory.Build(dto.ValidFor), culture));
        }
Example #5
0
        public void true_is_returned_when_all_validators_return_true()
        {
            var validator = _factory.Build("setnr=1|gamenr=1|total~*.5");

            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("setnr=1|gamenr=1|total=1.5")));
        }
        public void validation_of_correct_value_returns_true()
        {
            var validator = _factory.Build("setnr=1");

            Assert.IsTrue(validator.Validate(FeedMapperHelper.GetValidForAttributes("setnr=1")));
        }