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 }); }
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 }); }
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); }
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); }
public void Bonus_does_not_exist() { var result = BonusQueries.GetValidationResult(new IssueBonusByCs { PlayerId = PlayerId }); result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.BonusDoesNotExist); }
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); }
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); }
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)); }
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); }
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); }
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); }
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); }
public void Player_does_not_exist() { var result = BonusQueries.GetValidationResult(new FundInBonusApplication { PlayerId = Guid.NewGuid() }); result.Errors.Single().ErrorMessage.Should().Be(ValidatorMessages.PlayerDoesNotExist); }
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); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }