Esempio n. 1
0
        public async void Send_Failed_ExceptionErrors()
        {
            var provider = new DummyProvider(new Exception("Exception01"));

            var notification = Notification.GetInstance(_logger.Object, true);

            notification.AddProvider(provider);

            var result = await notification.Send(DummyProvider.DefaultName, new MessageParameterCollection());

            Assert.False(result.IsSuccess);
            Assert.NotEmpty(result.Errors);
            Assert.Equal("Exception01", result.Errors[0]);

            var failedMessage = LoggerHelper.FormatLogValues(LogMessages.Failed_Simple, DummyProvider.DefaultName);

            _logger.VerifyLog(LogLevel.Warning, failedMessage);
        }
Esempio n. 2
0
        public async void Send_Success()
        {
            var provider = new DummyProvider(new NotificationResult(true));

            var notification = Notification.GetInstance(_logger.Object, true);

            notification.AddProvider(provider);

            var result = await notification.Send(DummyProvider.DefaultName, new MessageParameterCollection());

            Assert.True(result.IsSuccess);
            Assert.Empty(result.Errors);

            var introMessage = LoggerHelper.FormatLogValues(LogMessages.Intro_SendingMessage, DummyProvider.DefaultName);

            _logger.VerifyLog(LogLevel.Debug, introMessage);

            var successMessage = LoggerHelper.FormatLogValues(LogMessages.Success_Simple, DummyProvider.DefaultName);

            _logger.VerifyLog(LogLevel.Debug, successMessage);
            _logger.VerifyLog(LogLevel.Warning, Times.Never());
        }