예제 #1
0
        public void Init()
        {
            m_CustomerSettledBets   = new List <CustomerBet>();
            m_CustomerUnSettledBets = new List <CustomerBet>();


            //Load AllUnique Customers from the bet history
            var customerIDs = m_repository.GetUniqueCustomerID();

            var settledRiskPolicies = new List <IRiskPolicy> {
                new WinningAtUnusalRatePolicy()
            };
            var undsettledRiskPolicies = new List <IRiskPolicy> {
                new BigWinRiskPolicy(), new HighlyUnusalStakePolicy(), new UnusalStakePolicy()
            };

            foreach (var customerID in customerIDs)
            {
                //Add Settled Bet for the given customer
                var settledBet = new CustomerBet();
                settledBet.Bet = new List <Bet>(m_repository.GetSettledBetForCustomer(customerID));
                settledBet.AverageBettingStake = settledBet.Bet.Average(a => a.Stake);
                m_CustomerSettledBets.Add(settledBet);

                //Run Policy on settled Bet
                settledRiskPolicies.ForEach(policy => policy.Run(settledBet));

                //Add Unsettled Bets for the given Customer
                var unSettledBet = new CustomerBet();
                unSettledBet.Bet = new List <Bet>(m_repository.GetUnSettledBetForCustomer(customerID));
                unSettledBet.AverageBettingStake = settledBet.AverageBettingStake;
                m_CustomerUnSettledBets.Add(unSettledBet);

                //Run policy on unsettled Bet
                undsettledRiskPolicies.ForEach(policy => policy.Run(unSettledBet));

                //Mark all these customer as Risky as they have risky history
                unSettledBet.Bet.ForEach(x => x.WinningAtUnusalRate = settledBet.Bet.First().WinningAtUnusalRate);
            }
        }
예제 #2
0
        public void ShouldLoadAllUniqueCustomers()
        {
            var uniqueCustomers = m_BetRepository.GetUniqueCustomerID();

            Assert.IsFalse(uniqueCustomers.GroupBy(n => n).Any(c => c.Count() > 1));
        }