示例#1
0
        public void Should_throw_exception_if_MaxAmountPerTransaction_less_MinAmountPerTransaction_in_update_paymentSettings()
        {
            // Arrange
            var saveSettingsCommand = new SavePaymentSettingsCommand();

            saveSettingsCommand.MinAmountPerTransaction = 2;
            saveSettingsCommand.MaxAmountPerTransaction = 1;

            // Act
            Action action = () => _commands.UpdateSettings(saveSettingsCommand);

            //Assert
            action.ShouldThrow <RegoException>().WithMessage("MaxminAmountPerTransactionError");
        }
        public void Update_payment_settings_limits_test()
        {
            // Arrange
            var paymentSettings = new PaymentSettings {
                Id = new Guid("50797305-5320-4086-BA1C-9D062DDF53D9")
            };

            _paymentRepository.PaymentSettings.Add(paymentSettings);

            var savePaymentSettingsCommand = new SavePaymentSettingsCommand();

            savePaymentSettingsCommand.Id = paymentSettings.Id;
            savePaymentSettingsCommand.MinAmountPerTransaction = 10;
            savePaymentSettingsCommand.MaxAmountPerTransaction = 20;
            savePaymentSettingsCommand.MaxAmountPerDay         = 30;
            savePaymentSettingsCommand.MaxTransactionPerDay    = 40;
            savePaymentSettingsCommand.MaxTransactionPerWeek   = 50;
            savePaymentSettingsCommand.MaxTransactionPerMonth  = 60;
            savePaymentSettingsCommand.PaymentMethod           = "XPAY";
            savePaymentSettingsCommand.PaymentGatewayMethod    = PaymentMethod.Online;
            // Act
            _commands.UpdateSettings(savePaymentSettingsCommand);

            //Assert
            var settings = _paymentRepository.PaymentSettings.Single(x => x.Id == paymentSettings.Id);

            settings.MinAmountPerTransaction.ShouldBeEquivalentTo(10);
            settings.MaxAmountPerTransaction.ShouldBeEquivalentTo(20);
            settings.MaxAmountPerDay.ShouldBeEquivalentTo(30);
            settings.MaxTransactionPerDay.ShouldBeEquivalentTo(40);
            settings.MaxTransactionPerWeek.ShouldBeEquivalentTo(50);
            settings.MaxTransactionPerMonth.ShouldBeEquivalentTo(60);
            settings.UpdatedBy.ShouldBeEquivalentTo(_actorInfoProvider.Actor.UserName);
            settings.UpdatedDate.Should().BeCloseTo(DateTime.Now, 5000);
        }
        public PaymentSettingSaveResult SaveSetting(SavePaymentSettingsCommand model)
        {
            string message;
            var    paymentSettingsId = model.Id;

            if (model.Id == Guid.Empty)
            {
                paymentSettingsId = _settingsCommands.AddSettings(model);
                message           = "CreatedSuccessfully";
            }
            else
            {
                _settingsCommands.UpdateSettings(model);
                message = "UpdatedSuccessfully";
            }

            return(new PaymentSettingSaveResult
            {
                Message = message,
                PaymentSettingsId = paymentSettingsId
            });
        }