Ejemplo n.º 1
0
        public void RedemptionCanceled_is_saved_in_event_store()
        {
            _bonus.Template.Rules.RewardTiers.Single().BonusTiers.Single().Reward = 100;
            _bonus.Template.Wagering.HasWagering = true;
            _bonus.Template.Wagering.Multiplier  = 3m;

            MakeDeposit(PlayerId, 100);

            var bonusRedemption = BonusRedemptions.Single();

            PlaceAndWinBet(20, 40, PlayerId);
            PlaceAndLoseBet(50, PlayerId);
            var model = new CancelBonusRedemption
            {
                PlayerId     = PlayerId,
                RedemptionId = bonusRedemption.Id
            };

            BonusCommands.CancelBonusRedemption(model);

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionCanceled).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionCanceled>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.MainBalanceAdjustment.Should().Be(40);
            data.BonusBalanceAdjustment.Should().Be(-40);
            data.NonTransferableAdjustment.Should().Be(-100);
            data.UnlockedAmount.Should().Be(bonusRedemption.LockedAmount);
        }
Ejemplo n.º 2
0
        public void Playable_balance_is_taken_into_account_to_trigger_wagering_threshold()
        {
            _bonus.Template.Wagering.Threshold = 125;
            MakeDeposit(PlayerId);

            PlaceAndLoseBet(175, PlayerId);
            BonusRedemptions.Single().RolloverState.Should().Be(RolloverStatus.ZeroedOut);
        }
Ejemplo n.º 3
0
        public void RedemptionIsClaimable_is_saved_in_event_store()
        {
            MakeDeposit(PlayerId);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionIsClaimable).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionIsClaimable>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
        }
Ejemplo n.º 4
0
        public decimal High_deposit_bonus_lock_amount_is_correct(bool isAfterWager)
        {
            var bonus = CreateBonusWithHighDepositTiers(false);

            bonus.Template.Wagering.HasWagering  = true;
            bonus.Template.Wagering.IsAfterWager = isAfterWager;

            MakeDeposit(PlayerId, 600);

            return(BonusRedemptions.Single().LockedAmount);
        }
Ejemplo n.º 5
0
        public void BonusRedeemed_is_saved_in_event_store()
        {
            MakeDeposit(PlayerId);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(BonusRedeemed).Name);
            var data     = JsonConvert.DeserializeObject <BonusRedeemed>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.PlayerId.Should().Be(PlayerId);
            data.BonusId.Should().Be(_bonus.Id);
            data.Amount.Should().Be(bonusRedemption.Amount);
        }
Ejemplo n.º 6
0
        public void RedemptionNegated_is_saved_in_event_store_when_deposit_is_unverified()
        {
            var depositId = SubmitDeposit(PlayerId);

            UnverifyDeposit(depositId, PlayerId);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionNegated).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionNegated>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.Reasons.Single().Should().Be("Deposit unverified");
        }
        public void Pending_expired_bonus_can_be_activated_during_claim_period()
        {
            var bonus = CreateFirstDepositBonus();

            bonus.DaysToClaim = 1;

            var depositId = SubmitDeposit(PlayerId);

            Assert.AreEqual(ActivationStatus.Pending, BonusRedemptions.Single().ActivationState);
            //expiring the bonus
            bonus.ActiveTo = bonus.ActiveTo.AddDays(-2);
            ApproveDeposit(depositId, PlayerId, 200);

            Assert.AreEqual(ActivationStatus.Activated, BonusRedemptions.Single().ActivationState);
        }
Ejemplo n.º 8
0
        public void RedemptionRolloverIssued_is_saved_in_event_store()
        {
            _bonus.Template.Rules.RewardTiers.Single().BonusTiers.Single().Reward = 100;
            _bonus.Template.Wagering.HasWagering = true;
            _bonus.Template.Wagering.Multiplier  = 2m;
            MakeDeposit(PlayerId);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionRolloverIssued).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionRolloverIssued>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.WageringRequrement.Should().Be(200);
            data.LockedAmount.Should().Be(300);
        }
Ejemplo n.º 9
0
        public void Qualification_ignores_fraudulent_status_for_Manual_by_CS_issuance()
        {
            MakeDeposit(PlayerId);
            var transaction = BonusRepository.Players.Single(p => p.Id == PlayerId).Wallets.SelectMany(t => t.Transactions).First();
            var bonus       = CreateFirstDepositBonus();

            DisableBonusesForPlayer(PlayerId);

            BonusCommands.IssueBonusByCs(new IssueBonusByCs
            {
                BonusId       = bonus.Id,
                PlayerId      = PlayerId,
                TransactionId = transaction.Id
            });

            BonusRedemptions.Single().ActivationState.Should().Be(ActivationStatus.Activated);
        }
Ejemplo n.º 10
0
        public void Can_issue_first_deposit_bonus()
        {
            MakeDeposit(PlayerId);
            var transaction = BonusRepository.Players.Single(p => p.Id == PlayerId).Wallets.SelectMany(t => t.Transactions).First();
            var bonus       = CreateFirstDepositBonus();

            BonusCommands.IssueBonusByCs(new IssueBonusByCs
            {
                BonusId       = bonus.Id,
                PlayerId      = PlayerId,
                TransactionId = transaction.Id
            });

            var bonusRedemption = BonusRedemptions.Single();

            bonusRedemption.ActivationState.Should().Be(ActivationStatus.Activated);
        }
Ejemplo n.º 11
0
        public void System_does_not_claim_ManualByPlayer_bonus_issued_by_CS()
        {
            MakeDeposit(PlayerId);
            var transaction = BonusRepository.Players.Single(p => p.Id == PlayerId).Wallets.SelectMany(t => t.Transactions).First();
            var bonus       = CreateFirstDepositBonus(mode: IssuanceMode.ManualByPlayer);

            BonusCommands.IssueBonusByCs(new IssueBonusByCs
            {
                BonusId       = bonus.Id,
                PlayerId      = PlayerId,
                TransactionId = transaction.Id
            });

            var bonusRedemption = BonusRedemptions.Single();

            bonusRedemption.ActivationState.Should().Be(ActivationStatus.Claimable);
        }
Ejemplo n.º 12
0
        public decimal Referral_bonus_lock_amount_is_correct(bool isAfterWager)
        {
            var referTier = new BonusTier
            {
                From   = 1,
                Reward = 10
            };

            var bonus = CreateBonusWithReferFriendTiers();

            bonus.Template.Rules.RewardTiers.Single().BonusTiers.Clear();
            bonus.Template.Rules.RewardTiers.Single().BonusTiers.Add(referTier);
            bonus.Template.Wagering.HasWagering  = true;
            bonus.Template.Wagering.IsAfterWager = isAfterWager;

            CompleteReferAFriendRequirments(PlayerId);

            return(BonusRedemptions.Single().LockedAmount);
        }
Ejemplo n.º 13
0
        public void Can_claim_percentage_reward_type_bonus()
        {
            var bonus = CreateFirstDepositBonus(mode: IssuanceMode.ManualByPlayer);

            bonus.Template.Rules.RewardType = BonusRewardType.Percentage;
            bonus.Template.Rules.RewardTiers.Single().Tiers.Single().Reward = 0.5m;

            MakeDeposit(PlayerId, 1000, bonusId: bonus.Id);

            var bonusRedemption = BonusRedemptions.Single();

            Assert.DoesNotThrow(() => BonusCommands.ClaimBonusRedemption(new ClaimBonusRedemption
            {
                PlayerId     = PlayerId,
                RedemptionId = bonusRedemption.Id
            }));
            bonusRedemption.Amount.Should().Be(500);
            bonusRedemption.ActivationState.Should().Be(ActivationStatus.Activated);
        }
Ejemplo n.º 14
0
        public void RedemptionRolloverZeroedOut_is_saved_in_event_store()
        {
            _bonus.Template.Rules.RewardTiers.Single().BonusTiers.Single().Reward = 50;
            _bonus.Template.Wagering.HasWagering = true;
            _bonus.Template.Wagering.Multiplier  = 20m;
            _bonus.Template.Wagering.Threshold   = 150m;
            MakeDeposit(PlayerId);

            PlaceAndWinBet(250, 100, PlayerId);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionRolloverZeroedOut).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionRolloverZeroedOut>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.UnlockedAmount.Should().Be(bonusRedemption.LockedAmount);
            data.BonusBalanceAdjustment.Should().Be(-100);
            data.MainBalanceAdjustment.Should().Be(100);
        }
Ejemplo n.º 15
0
        public decimal Fundin_bonus_lock_amount_is_correct(bool isAfterWager)
        {
            var bonus = CreateFirstDepositBonus();

            bonus.Template.Info.TemplateType = BonusType.FundIn;
            var brandWalletId = bonus.Template.Info.Brand.WalletTemplates.First().Id;

            bonus.Template.Rules.FundInWallets = new List <BonusFundInWallet>
            {
                new BonusFundInWallet {
                    WalletId = brandWalletId
                }
            };
            bonus.Template.Wagering.HasWagering  = true;
            bonus.Template.Wagering.IsAfterWager = isAfterWager;

            MakeDeposit(PlayerId, 100);
            MakeFundIn(PlayerId, brandWalletId, 100);

            return(BonusRedemptions.Single().LockedAmount);
        }
Ejemplo n.º 16
0
        public void Template_update_does_not_affect_already_redemed_bonuses()
        {
            var bonus = CreateFirstDepositBonus(mode: IssuanceMode.AutomaticWithCode);

            bonus.Template.Rules.RewardType = BonusRewardType.Percentage;
            bonus.Template.Rules.RewardTiers.Single().Tiers.Single().MaxAmount = 10;
            BonusRepository.Templates.Add(bonus.Template);

            var depositId = SubmitDeposit(PlayerId, 200, bonus.Code);

            var updatedBonus = CreateFirstDepositBonus();

            updatedBonus.Template.Id      = bonus.Template.Id;
            updatedBonus.Template.Version = 1;
            updatedBonus.Version          = 1;
            updatedBonus.Template.Rules.RewardTiers.Single().Tiers.Single().MaxAmount = 10;
            BonusRepository.Templates.Add(updatedBonus.Template);

            ApproveDeposit(depositId, PlayerId, 200);
            Assert.AreEqual(10, BonusRedemptions.Single().Amount);
        }
Ejemplo n.º 17
0
        public void Lock_is_released_from_correct_wallets_when_bonus_is_canceled()
        {
            var player        = BonusRepository.Players.Single(p => p.Id == PlayerId);
            var productWallet = player.Wallets.Single(a => a.Template.IsMain == false);
            var bonus         = CreateFirstDepositBonus();

            bonus.Template.Info.TemplateType   = BonusType.FundIn;
            bonus.Template.Rules.FundInWallets = new List <BonusFundInWallet>
            {
                new BonusFundInWallet {
                    WalletId = productWallet.Template.Id
                }
            };
            bonus.Template.Wagering.HasWagering  = true;
            bonus.Template.Wagering.Multiplier   = 0.1m;
            bonus.Template.Info.WalletTemplateId = _mainWallet.Template.Id;

            MakeDeposit(PlayerId, 100);
            MakeFundIn(PlayerId, productWallet.Template.Id, 100);
            var model = new CancelBonusRedemption
            {
                PlayerId     = PlayerId,
                RedemptionId = BonusRedemptions.Single().Id
            };

            BonusCommands.CancelBonusRedemption(model);

            _mainWallet.BonusLock.Should().Be(0);
            _mainWallet.Locks
            .Single(tr => tr.Amount == 27)
            .UnlockedOn
            .Should()
            .HaveValue();
            productWallet.BonusLock.Should().Be(0);
            productWallet.Locks
            .Single(tr => tr.Amount == 100)
            .UnlockedOn
            .Should()
            .HaveValue();
        }
Ejemplo n.º 18
0
        public void Before_wager_bonus_isnot_issued_before_wagering_requirement_is_fulfilled()
        {
            MakeDeposit(PlayerId);
            var transaction = BonusRepository.Players.Single(p => p.Id == PlayerId).Wallets.SelectMany(t => t.Transactions).First();
            var bonus       = CreateFirstDepositBonus(mode: IssuanceMode.ManualByCs);

            bonus.Template.Wagering.HasWagering  = true;
            bonus.Template.Wagering.Multiplier   = 2;
            bonus.Template.Wagering.IsAfterWager = true;

            BonusCommands.IssueBonusByCs(new IssueBonusByCs
            {
                BonusId       = bonus.Id,
                PlayerId      = PlayerId,
                TransactionId = transaction.Id
            });

            var bonusRedemption = BonusRedemptions.Single();

            bonusRedemption.ActivationState.Should().Be(ActivationStatus.Pending);
            bonusRedemption.RolloverState.Should().Be(RolloverStatus.Active);
        }
Ejemplo n.º 19
0
        public void RedemptionNegated_is_saved_in_event_store_when_qualification_fails()
        {
            var riskLevelId = _bonus.Template.Info.Brand.RiskLevels.Single().Id;

            _bonus.Template.Availability.ExcludeRiskLevels = new List <RiskLevelExclude> {
                new RiskLevelExclude {
                    ExcludedRiskLevelId = riskLevelId
                }
            };

            var depositId = SubmitDeposit(PlayerId);

            TagPlayerWithFraudRiskLevel(PlayerId, riskLevelId);
            ApproveDeposit(depositId, PlayerId, 200);

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(RedemptionNegated).Name);
            var data     = JsonConvert.DeserializeObject <RedemptionNegated>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.Reasons.Single().Should().Be("Player is in excluded risk level");
        }
Ejemplo n.º 20
0
        public void BonusRedeemedByCs_is_saved_in_event_store()
        {
            _bonus.Template.Info.Mode = IssuanceMode.ManualByCs;
            MakeDeposit(PlayerId);
            var transaction = BonusRepository.Players.Single(p => p.Id == PlayerId).Wallets.SelectMany(t => t.Transactions).First();

            BonusCommands.IssueBonusByCs(new IssueBonusByCs
            {
                BonusId       = _bonus.Id,
                PlayerId      = PlayerId,
                TransactionId = transaction.Id
            });

            var bonusRedemption = BonusRedemptions.Single();

            var theEvent = _eventRepository.Events.Single(e => e.DataType == typeof(BonusRedeemed).Name);
            var data     = JsonConvert.DeserializeObject <BonusRedeemed>(theEvent.Data);

            data.AggregateId.Should().Be(bonusRedemption.Id);
            data.PlayerId.Should().Be(PlayerId);
            data.BonusId.Should().Be(_bonus.Id);
            data.Amount.Should().Be(bonusRedemption.Amount);
            data.IssuedByCs.Should().BeTrue();
        }