Пример #1
0
        private async Task <string> GetFeedbackMessageContent(string key, string languageCode)
        {
            var smsContents = await _stringsResourcesService.GetSmsContentResources(!string.IsNullOrEmpty(languageCode)
                                                                                    ?languageCode
                                                                                    : "en");

            smsContents.Value.TryGetValue(key, out var message);

            if (message == null)
            {
                _loggerAdapter.Warn($"No sms content resource found for key '{key}'");
            }

            return(message);
        }
Пример #2
0
        public async Task SendNotificationsForNewAlert_ShouldSendSmsToAllSupervisorsAndQueueCheckBack()
        {
            // arrange
            _testData.WhenAnAlertAreTriggered.GenerateData().AddToDbContext();
            var alert = _testData.WhenAnAlertAreTriggered.EntityData.Alerts.Single();
            var stringResourceResult = new Dictionary <string, string> {
                { SmsContentKey.Alerts.AlertTriggered, "Alert triggered!" }
            };

            _stringsResourcesServiceMock.GetSmsContentResources(Arg.Any <string>())
            .Returns(Result.Success <IDictionary <string, string> >(stringResourceResult));
            _nyssReportApiConfigMock.BaseUrl = "http://example.com";

            // act
            await _alertService.SendNotificationsForNewAlert(alert, new GatewaySetting { ApiKey = "123" });

            // assert
            await _queuePublisherServiceMock.Received(1).QueueAlertCheck(alert.Id);
        }
Пример #3
0
        private async Task <string> GetSmsMessageContent(string key, string languageCode)
        {
            var smsContents = await _stringsResourcesService.GetSmsContentResources(!string.IsNullOrEmpty(languageCode)
                                                                                    ?languageCode
                                                                                    : "en");

            smsContents.Value.TryGetValue(key, out var message);

            if (message == null)
            {
                throw new ArgumentException($"No sms content resource found for key '{key}' (languageCode: {languageCode})");
            }

            if (message?.Length > 160)
            {
                _loggerAdapter.Warn($"SMS content with key '{key}' ({languageCode}) is longer than 160 characters.");
            }

            return(message);
        }
Пример #4
0
        public async Task <string> GenerateEscalatedAlertSms(string languageCode)
        {
            var translatedSmsTexts = await _stringsResourcesService.GetSmsContentResources(languageCode);

            return(GetTranslation("sms.alertEscalated", languageCode, translatedSmsTexts.Value));
        }