예제 #1
0
        public ToggleBonusStatusResponse ChangeStatus(ToggleBonusStatus model)
        {
            var validationResult = _bonusQueries.GetValidationResult(model);

            if (!validationResult.IsValid)
            {
                return(ValidationErrorResponse <ToggleBonusStatusResponse>(validationResult));
            }

            _bonusCommands.ChangeBonusStatus(model);
            return(new ToggleBonusStatusResponse {
                Success = true
            });
        }
예제 #2
0
        public AddEditTemplateResponse CreateEdit(CreateUpdateTemplate model)
        {
            var validationResult = _bonusQueries.GetValidationResult(model);

            if (!validationResult.IsValid)
            {
                return(ValidationErrorResponse <AddEditTemplateResponse>(validationResult));
            }

            var identifier = _bonusCommands.AddUpdateTemplate(model);

            return(new AddEditTemplateResponse {
                Success = true, Id = identifier.Id, Version = identifier.Version
            });
        }
예제 #3
0
        public bool Status_of_bonus_redemption_is_validated_during_cancellation(RolloverStatus status)
        {
            var bonus = CreateFirstDepositBonus();

            bonus.Template.Wagering.HasWagering = true;
            bonus.Template.Wagering.Multiplier  = 3m;

            MakeDeposit(PlayerId);
            var bonusRedemption = BonusRedemptions.First();

            bonusRedemption.RolloverState = status;

            var validationResult = BonusQueries.GetValidationResult(new CancelBonusRedemption
            {
                PlayerId     = PlayerId,
                RedemptionId = bonusRedemption.Id
            });

            if (validationResult.IsValid == false)
            {
                validationResult.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusRedemptionStatusIsIncorrectForCancellation);
            }

            return(validationResult.IsValid);
        }
예제 #4
0
        public void Unknown_gameId_in_wagering_contribution_isnt_valid()
        {
            var gameId = Guid.NewGuid();

            BonusRepository.Games.Add(new Game());
            BonusRepository.Games.Add(new Game {
                Id = gameId
            });
            _model.Wagering = new CreateUpdateTemplateWagering
            {
                GameContributions = new List <CreateUpdateGameContribution>
                {
                    new CreateUpdateGameContribution
                    {
                        GameId       = gameId,
                        Contribution = 0
                    },
                    new CreateUpdateGameContribution
                    {
                        GameId       = new Guid(),
                        Contribution = 1
                    }
                }
            };

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateOneOfGameContributionsPointsToInvalidGame, message);
        }
        public void Can_not_change_status_of_non_existent_bonus()
        {
            var result = BonusQueries.GetValidationResult(new ToggleBonusStatus {
                Id = Guid.Empty, IsActive = true
            });

            result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusDoesNotExist);
        }
예제 #6
0
        public void Bonus_does_not_exist()
        {
            var result = BonusQueries.GetValidationResult(new IssueBonusByCs {
                PlayerId = PlayerId
            });

            result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusDoesNotExist);
        }
예제 #7
0
        public void Can_not_update_non_existing_bonus()
        {
            _model.Id = Guid.NewGuid();

            var validationResult = BonusQueries.GetValidationResult(_model);

            Assert.AreEqual(ValidatorMessages.BonusDoesNotExist, validationResult.Errors.Single().ErrorMessage);
        }
예제 #8
0
        public void Player_does_not_exist_validation()
        {
            var validationResult = BonusQueries.GetValidationResult(new CancelBonusRedemption {
                PlayerId = Guid.NewGuid(), RedemptionId = Guid.NewGuid()
            });

            validationResult.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.PlayerDoesNotExist);
        }
예제 #9
0
        public void Can_not_update_non_existing_template()
        {
            _model.Id = Guid.NewGuid();

            var validationResult = BonusQueries.GetValidationResult(_model);

            Assert.AreEqual(1, validationResult.Errors.Count(e => e.ErrorMessage == ValidatorMessages.TemplateDoesNotExist));
        }
예제 #10
0
        public void Can_not_cancel_a_non_existent_bonus()
        {
            var validationResult = BonusQueries.GetValidationResult(new CancelBonusRedemption {
                PlayerId = PlayerId, RedemptionId = Guid.NewGuid()
            });

            validationResult.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusRedemptionDoesNotExist);
        }
예제 #11
0
        public void Activity_dates_should_form_range()
        {
            _model.ActiveFrom = DateTimeOffset.Now.ToBrandOffset(_brandTimezoneId).AddDays(2).Date;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusActivityRangeIsInvalid, message);
        }
예제 #12
0
        public void Zero_length_duration_validation_works()
        {
            _model.DurationType = DurationType.StartDateBased;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusDurationIsZeroLength, message);
        }
예제 #13
0
        public void Days_to_claim_cant_be_negative()
        {
            _model.DaysToClaim = -1;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusDaysToClaimIsNegative, message);
        }
예제 #14
0
        public void Player_does_not_exist()
        {
            var result = BonusQueries.GetValidationResult(new FundInBonusApplication
            {
                PlayerId = Guid.NewGuid()
            });

            result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.PlayerDoesNotExist);
        }
예제 #15
0
        public void Template_does_not_exist_validation_works()
        {
            _model.TemplateId = Guid.NewGuid();

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusTemplateIsNotAssigned, message);
        }
예제 #16
0
        public void Can_not_update_not_current_version_template()
        {
            _model.Info       = _info;
            _template.Version = 1000;

            var validationResult = BonusQueries.GetValidationResult(_model);

            Assert.AreEqual(1, validationResult.Errors.Count(e => e.ErrorMessage == ValidatorMessages.TemplateVersionIsNotCurrent));
        }
예제 #17
0
        public void Transaction_does_not_exist()
        {
            var bonus  = CreateFirstDepositBonus();
            var result = BonusQueries.GetValidationResult(new IssueBonusByCs {
                BonusId = bonus.Id, PlayerId = PlayerId
            });

            result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.TransactionDoesNotExist);
        }
예제 #18
0
        public void Code_cant_contain_special_characters()
        {
            _model.Code = "Foo Bar$";

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusCodeIsInvalid, message);
        }
예제 #19
0
        public void Name_is_required_validation_works()
        {
            _model.Name = null;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.NameIsNotSpecified, message);
        }
예제 #20
0
        public void Reward_amount_should_be_greater_than_zero()
        {
            _rules.RewardTiers.Single().BonusTiers.Single().Reward = 0;
            _model.Rules = _rules;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateRewardValueIsInvalid, message);
        }
예제 #21
0
        public void Duration_is_over_activity_date_range_validation_works()
        {
            _model.DurationType = DurationType.StartDateBased;
            _model.DurationDays = 5;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusDurationDaterangeIsIncorrect, message);
        }
예제 #22
0
        public void Bonus_activeTo_forms_active_daterange_validation_works()
        {
            _model.ActiveFrom = DateTimeOffset.Now.AddDays(-2).ToBrandOffset(_brandTimezoneId).Date;
            _model.ActiveTo   = DateTimeOffset.Now.AddDays(-1).ToBrandOffset(_brandTimezoneId).Date;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusActiveToIsInvalid, message);
        }
예제 #23
0
        public void Name_cant_be_empty()
        {
            _info.Name  = string.Empty;
            _model.Info = _info;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.NameIsNotSpecified, message);
        }
예제 #24
0
        public void Template_should_have_receiving_wallet_that_is_brand_related()
        {
            _info.WalletTemplateId = Guid.NewGuid();
            _model.Info            = _info;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateReceivingWalletIsInvalid, message);
        }
예제 #25
0
        public void Template_should_have_receiving_wallet()
        {
            _info.WalletTemplateId = Guid.Empty;
            _model.Info            = _info;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateReceivingWalletIsNotSpecified, message);
        }
예제 #26
0
        public void Reward_amount_limit_cant_be_negative()
        {
            _rules.RewardTiers.Single().RewardAmountLimit = -1;
            _model.Rules = _rules;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateRewardLimitIsNegative, message);
        }
예제 #27
0
        public void Bonus_does_not_exist_if_BonusCode_is_passed()
        {
            var result = BonusQueries.GetValidationResult(new FundInBonusApplication
            {
                PlayerId  = PlayerId,
                BonusCode = TestDataGenerator.GetRandomString()
            });

            result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusDoesNotExist);
        }
예제 #28
0
        public void Currency_not_specified_validation_works()
        {
            _rules.RewardTiers = new List <CreateUpdateRewardTier>();
            _model.Rules       = _rules;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateCurrenciesAreEmpty, message);
        }
예제 #29
0
        public void Fund_in_no_wallets_validation_works()
        {
            _template.Info.TemplateType = BonusType.FundIn;
            _model.Rules = _rules;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.TemplateNoFundInWallets, message);
        }
예제 #30
0
        public void Code_is_required_validation_works_for_AutomaticWithBonusCode_issuance_mode()
        {
            BonusRepository.Templates.Single(t => t.Id == _model.TemplateId).Info.Mode = IssuanceMode.AutomaticWithCode;
            _model.Code = null;

            var validationResult = BonusQueries.GetValidationResult(_model);
            var message          = validationResult.Errors.Single().ErrorMessage;

            Assert.AreEqual(ValidatorMessages.BonusCodeIsNotSpecified, message);
        }