private static void ValidateMapping(mappingsMapping msg, MarketMappingCacheItem ci) { var ciMarketId = ci.MarketSubTypeId == null?ci.MarketTypeId.ToString() : $"{ci.MarketTypeId}:{ci.MarketSubTypeId}"; Assert.AreEqual(msg.market_id, ciMarketId); if (!string.IsNullOrEmpty(msg.product_ids)) { var ids = msg.product_ids.Split(new[] { SdkInfo.MarketMappingProductsDelimiter }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); Assert.AreEqual(ids.Count, ci.ProducerIds.Count()); foreach (var id in ids) { Assert.IsTrue(ci.ProducerIds.Contains(id), $"Missing producerId:{id}."); } } else { Assert.AreEqual(1, ci.ProducerIds.Count()); Assert.AreEqual(msg.product_id, ci.ProducerIds.First()); } Assert.AreEqual(msg.sport_id, ci.SportId.ToString()); Assert.AreEqual(msg.sov_template, ci.SovTemplate); Assert.AreEqual(msg.valid_for, ci.Validator.ToString()); if (msg.mapping_outcome != null) { Assert.AreEqual(msg.mapping_outcome.Length, ci.OutcomeMappings.Count()); for (var i = 0; i < msg.mapping_outcome.Length; i++) { ValidateMappingOutcome(msg.mapping_outcome[i], ci.OutcomeMappings.ToArray()[i]); } } }
/// <summary> /// Initializes a new instance of the <see cref="MarketMapping"/> class /// </summary> /// <param name="cacheItem">A <see cref="MarketMappingCacheItem"/> containing mapping info</param> internal MarketMapping(MarketMappingCacheItem cacheItem) { Guard.Argument(cacheItem, nameof(cacheItem)).NotNull(); ProducerIds = cacheItem.ProducerIds; SportId = cacheItem.SportId; MarketTypeId = cacheItem.MarketTypeId; MarketSubTypeId = cacheItem.MarketSubTypeId; MarketId = string.IsNullOrEmpty(cacheItem.OrgMarketId) ? MarketSubTypeId == null ? MarketTypeId.ToString() : $"{MarketTypeId}:{MarketSubTypeId}" : cacheItem.OrgMarketId; SovTemplate = cacheItem.SovTemplate; ValidFor = cacheItem.ValidFor; OutcomeMappings = cacheItem.OutcomeMappings?.Select(o => new OutcomeMapping(o)); _validator = cacheItem.Validator; }
/// <summary> /// Initializes a new instance of the <see cref="MarketMapping"/> class /// </summary> /// <param name="cacheItem">A <see cref="MarketMappingCacheItem"/> containing mapping info</param> internal MarketMapping(MarketMappingCacheItem cacheItem) { Contract.Requires(cacheItem != null); ProducerId = cacheItem.ProducerId; ProducerIds = cacheItem.ProducerIds; SportId = cacheItem.SportId; MarketTypeId = cacheItem.MarketTypeId; MarketSubTypeId = cacheItem.MarketSubTypeId; MarketId = string.IsNullOrEmpty(cacheItem.OrgMarketId) ? MarketSubTypeId == null ? MarketTypeId.ToString() : $"{MarketTypeId}:{MarketSubTypeId}" : cacheItem.OrgMarketId; SovTemplate = cacheItem.SovTemplate; ValidFor = cacheItem.ValidFor; OutcomeMappings = cacheItem.OutcomeMappings?.Select(o => new OutcomeMapping(o)); _validator = cacheItem.Validator; }