public void Cannot_execute_Commands_without_permissions() { // Arrange LogWithNewAdmin(Modules.TransferSettings, Permissions.View); // Act Assert.Throws <InsufficientPermissionsException>(() => _transferSettingsCommands.AddSettings(new SaveTransferSettingsCommand())); Assert.Throws <InsufficientPermissionsException>(() => _transferSettingsCommands.UpdateSettings(new SaveTransferSettingsCommand())); Assert.Throws <InsufficientPermissionsException>(() => _transferSettingsCommands.Enable(new Guid(), "", "12345")); Assert.Throws <InsufficientPermissionsException>(() => _transferSettingsCommands.Disable(new Guid(), "", "12345")); }
public string Save(SaveTransferSettingsCommand model) { model.TimezoneId = _brandQueries.GetBrandOrNull(model.Brand).TimezoneId; try { string message; Guid transferSettingsId = model.Id; if (model.Id == Guid.Empty) { transferSettingsId = _settingsCommands.AddSettings(model); message = "CreatedSuccessfully"; } else { _settingsCommands.UpdateSettings(model); message = "UpdatedSuccessfully"; } return(SerializeJson(new { Result = "success", Data = message, Id = transferSettingsId })); } catch (RegoException regoEx) { return(SerializeJson(new { Result = "failed", Data = regoEx.Message })); } catch (ValidationError e) { return(SerializeJson(new { Result = "failed", Data = e.ErrorMessage })); } }
public void Update_transfer_settgins_limits_test() { // Arrange var transferSettings = new TransferSettings(); transferSettings.Id = new Guid("84c60b9f-16ad-49e0-bb9a-0e7670054dd5"); _paymentRepository.TransferSettings.Add(transferSettings); var saveTransferSettingsCommand = new SaveTransferSettingsCommand(); saveTransferSettingsCommand.Id = transferSettings.Id; saveTransferSettingsCommand.MinAmountPerTransaction = 10; saveTransferSettingsCommand.MaxAmountPerTransaction = 20; saveTransferSettingsCommand.MaxAmountPerDay = 30; saveTransferSettingsCommand.MaxTransactionPerDay = 40; saveTransferSettingsCommand.MaxTransactionPerWeek = 50; saveTransferSettingsCommand.MaxTransactionPerMonth = 60; saveTransferSettingsCommand.TimezoneId = TestDataGenerator.GetRandomTimeZone().Id; // Act _commands.UpdateSettings(saveTransferSettingsCommand); //Assert var settings = _paymentRepository.TransferSettings.Single(x => x.Id == transferSettings.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(_securityProvider.Actor.UserName); settings.UpdatedDate.Should().BeCloseTo(DateTime.Now, 5000); }