public async Task DeleteSmsGateway_WhenSmsGatewayExists_ShouldReturnSuccess() { // Arrange const int existingSmsGatewayId = 1; var gatewaySettings = new[] { new GatewaySetting { Id = existingSmsGatewayId, Name = "Name", ApiKey = "api-key", NationalSocietyId = 1, GatewayType = GatewayType.SmsEagle } }; var gatewaySettingsMockDbSet = gatewaySettings.AsQueryable().BuildMockDbSet(); _nyssContextMock.GatewaySettings.Returns(gatewaySettingsMockDbSet); _nyssContextMock.GatewaySettings.FindAsync(existingSmsGatewayId).Returns(gatewaySettings[0]); // Act var result = await _smsGatewayService.Delete(existingSmsGatewayId); // Assert _nyssContextMock.GatewaySettings.Received(1).Remove(Arg.Is <GatewaySetting>(gs => gs.Id == existingSmsGatewayId)); await _nyssContextMock.Received(1).SaveChangesAsync(); var content = Arg.Any <string>(); await _smsGatewayBlobProviderMock.Received(1).UpdateApiKeys(content); result.IsSuccess.ShouldBeTrue(); result.Message.Key.ShouldBe(ResultKey.NationalSociety.SmsGateway.SuccessfullyDeleted); }
private async Task RemoveApiKeys(int nationalSocietyId) { var gatewaysResult = await _smsGatewayService.List(nationalSocietyId); ThrowIfErrorResult(gatewaysResult); foreach (var gateway in gatewaysResult.Value) { var deleteResult = await _smsGatewayService.Delete(gateway.Id); ThrowIfErrorResult(deleteResult); } }
public Task <Result> Delete(int smsGatewayId) => _smsGatewayService.Delete(smsGatewayId);