Ejemplo n.º 1
0
        public async Task UpdateSmsGateway_WhenSmsGatewayExists_ShouldReturnSuccess()
        {
            // Arrange
            const int smsGatewayId = 1;

            var nationalSocieties = new[]
            {
                new NationalSociety
                {
                    Id   = 1,
                    Name = "National Society"
                }
            };

            var nationalSocietiesMockDbSet = nationalSocieties.AsQueryable().BuildMockDbSet();

            _nyssContextMock.NationalSocieties.Returns(nationalSocietiesMockDbSet);

            var gatewaySettings = new[]
            {
                new GatewaySetting
                {
                    Id                = smsGatewayId,
                    Name              = "Name",
                    ApiKey            = "api-key",
                    NationalSocietyId = 1,
                    GatewayType       = GatewayType.SmsEagle
                }
            };

            var gatewaySettingsMockDbSet = gatewaySettings.AsQueryable().BuildMockDbSet();

            _nyssContextMock.GatewaySettings.Returns(gatewaySettingsMockDbSet);
            _nyssContextMock.GatewaySettings.FindAsync(smsGatewayId).Returns(gatewaySettings[0]);

            var gatewaySettingRequestDto = new GatewaySettingRequestDto
            {
                Name        = "Updated SMS Gateway",
                ApiKey      = "updated-api-key",
                GatewayType = GatewayType.SmsEagle
            };

            // Act
            var result = await _smsGatewayService.Edit(smsGatewayId, gatewaySettingRequestDto);

            // Assert
            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.SuccessfullyUpdated);
        }
Ejemplo n.º 2
0
 public Task <Result> Edit(int smsGatewayId, [FromBody] GatewaySettingRequestDto gatewaySettingRequestDto) =>
 _smsGatewayService.Edit(smsGatewayId, gatewaySettingRequestDto);