private void TestOutcomeValues(IOutcomeOdds entity, oddsChangeMarketOutcome record)
 {
     Assert.IsNotNull(entity);
     Assert.AreEqual(entity.Id, record.id, "Outcome Id does not match");
     Assert.AreEqual(entity.Active, record.activeSpecified ? (bool?)(record.active == 1) : null);
     Assert.AreEqual(entity.Probabilities, record.probabilitiesSpecified ? (double?)record.probabilities : null);
     Assert.AreEqual(entity.GetOdds(OddsDisplayType.Decimal), record.odds);
     Assert.IsNotNull(entity.GetOdds(OddsDisplayType.American));
     if (entity.GetOdds(OddsDisplayType.American).HasValue)
     {
         Assert.IsTrue(Math.Abs(entity.GetOdds(OddsDisplayType.American).Value) > 0);
     }
 }
        private IAdditionalProbabilities GetAdditionalProbabilities(oddsChangeMarketOutcome outcome)
        {
            if (!outcome.win_probabilitiesSpecified &&
                !outcome.lose_probabilitiesSpecified &&
                !outcome.half_win_probabilitiesSpecified &&
                !outcome.half_lose_probabilitiesSpecified &&
                !outcome.refund_probabilitiesSpecified)
            {
                return(null);
            }

            return(new AdditionalProbabilities(
                       outcome.win_probabilitiesSpecified ? outcome.win_probabilities : (double?)null,
                       outcome.lose_probabilitiesSpecified ? outcome.lose_probabilities : (double?)null,
                       outcome.half_win_probabilitiesSpecified ? outcome.half_win_probabilities : (double?)null,
                       outcome.half_lose_probabilitiesSpecified ? outcome.half_lose_probabilities : (double?)null,
                       outcome.refund_probabilitiesSpecified ? outcome.refund_probabilities : (double?)null));
        }
        /// <summary>
        /// Gets the new <see cref="IOutcomeOdds"/> instances
        /// </summary>
        /// <param name="sportEvent">The <see cref="ISportEvent"/> associated with the market</param>
        /// <param name="nameProvider">The <see cref="INameProvider"/> used to generate outcome name</param>
        /// <param name="mappingProvider">The <see cref="IMarketMappingProvider"/> used to provide market mapping</param>
        /// <param name="outcome">The <see cref="oddsChangeMarketOutcome"/> representing the outcome to be mapped</param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="outcomeDefinition">The associated <see cref="IOutcomeDefinition"/></param>
        /// <returns>IOutcomeOdds</returns>
        protected virtual IOutcomeOdds GetOutcomeWithOdds(ISportEvent sportEvent,
                                                          INameProvider nameProvider,
                                                          IMarketMappingProvider mappingProvider,
                                                          oddsChangeMarketOutcome outcome,
                                                          IEnumerable <CultureInfo> cultures,
                                                          IOutcomeDefinition outcomeDefinition)
        {
            var    isValidPlayerOutcome = false;
            IMatch match = null;

            if (outcome.teamSpecified)
            {
                match = sportEvent as IMatch;
                isValidPlayerOutcome = !(match == null || outcome.team < 1 || outcome.team > 2);
            }

            if (isValidPlayerOutcome)
            {
                return(new PlayerOutcomeOdds(outcome.id,
                                             outcome.activeSpecified ? (bool?)(outcome.active != 0) : null,
                                             outcome.odds,
                                             outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null,
                                             nameProvider,
                                             mappingProvider,
                                             match,
                                             outcome.team,
                                             cultures,
                                             outcomeDefinition,
                                             GetAdditionalProbabilities(outcome)));
            }

            return(new OutcomeOdds(outcome.id,
                                   outcome.activeSpecified ? (bool?)(outcome.active != 0) : null,
                                   outcome.odds,
                                   outcome.probabilitiesSpecified ? (double?)outcome.probabilities : null,
                                   nameProvider,
                                   mappingProvider,
                                   cultures,
                                   outcomeDefinition,
                                   GetAdditionalProbabilities(outcome)));
        }
예제 #4
0
        private static ValidationResult ValidateOddsChangeOutcomes(FeedMessage message, oddsChangeMarket market, oddsChangeMarketOutcome outcome, ValidationResult currentResult)
        {
            if (outcome.activeSpecified && (outcome.active < 0 || outcome.active > 1))
            {
                LogWarning(message, $"markets[{market.id}].outcomes[{outcome.id}].active", outcome.active);
                currentResult = ValidationResult.PROBLEMS_DETECTED;
            }

            if (outcome.teamSpecified)
            {
                if (message.EventURN.TypeGroup != ResourceTypeGroup.MATCH)
                {
                    LogWarning(message, $"Player outcome=[marketId={market.id}, outcomeId={outcome.id}] cannot be mapped to IPlayerOutcomeOdds because associated event[id={message.EventURN}] is not an match", outcome.team);
                    currentResult = ValidationResult.PROBLEMS_DETECTED;
                }

                if (outcome.team < 1 || outcome.team > 2)
                {
                    LogWarning(message, $"Player outcome=[marketId={market.id}, outcomeId={outcome.id}] cannot be mapped to IPlayerOutcomeOdds because team attribute value {outcome.team} is out of range", outcome.team);
                    currentResult = ValidationResult.PROBLEMS_DETECTED;
                }
            }
            return(currentResult);
        }