Exemplo n.º 1
0
        public async Task CheckAlert_WhenAlertIsStillPending_ShouldNotifyHeadManager()
        {
            // arrange
            _testData.WhenAnAlertAreTriggered.GenerateData().AddToDbContext();
            var alert = _testData.WhenAnAlertAreTriggered.EntityData.Alerts.Single();
            var stringResourceResult = new Dictionary <string, string>
            {
                { EmailContentKey.AlertHasNotBeenHandled.Subject, "Alert escalated subject" },
                { EmailContentKey.AlertHasNotBeenHandled.Body, "Alert escalated body" }
            };

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

            // act
            await _alertService.CheckIfAlertHasBeenHandled(alert.Id);

            // assert
            await _queuePublisherServiceMock.Received(1).SendEmail(Arg.Any <(string, string)>(), Arg.Any <string>(), Arg.Any <string>());
        }
Exemplo n.º 2
0
        private async Task <string> GetEmailMessageContent(string key, string languageCode)
        {
            var contents = await _stringsResourcesService.GetEmailContentResources(!string.IsNullOrEmpty(languageCode)
                                                                                   ?languageCode
                                                                                   : "en");

            if (!contents.Value.TryGetValue(key, out var message))
            {
                throw new ArgumentException($"No email content resource found for key '{key}' (languageCode: {languageCode})");
            }

            return(message);
        }