Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public Task <Result> Delete(int smsGatewayId) =>
 _smsGatewayService.Delete(smsGatewayId);