Esempio n. 1
0
        public async Task GetNotificationsMessageByIds_GetMessage()
        {
            //Arrange
            var id             = Guid.NewGuid().ToString();
            var notificationId = Guid.NewGuid().ToString();
            var message        = new EmailNotificationMessageEntity {
                Id = id, NotificationType = nameof(EmailNotificationMessage), NotificationId = notificationId
            };
            var messages = new List <NotificationMessageEntity> {
                message
            };

            _repositoryMock.Setup(n => n.GetMessagesByIdsAsync(new[] { id })).ReturnsAsync(messages.ToArray());
            var notification = AbstractTypeFactory <Notification> .TryCreateInstance(nameof(RegistrationEmailNotification));

            notification.Id = notificationId;
            _notificationServiceMock.Setup(n => n.GetByIdsAsync(new[] { notificationId }, null)).ReturnsAsync(new[] { notification });

            //Act
            var result = await _notificationMessageService.GetNotificationsMessageByIds(new[] { id });

            //Assert
            Assert.NotNull(result);
            Assert.Contains(result, r => r.Id.Equals(id));
        }
Esempio n. 2
0
        public async Task GetNotificationsMessageByIds_GetMessage()
        {
            //Arrange
            string id      = Guid.NewGuid().ToString();
            var    message = new NotificationMessageEntity {
                Id = id, NotificationType = nameof(EmailNotificationMessage)
            };
            var messages = new List <NotificationMessageEntity> {
                message
            };

            _repositoryMock.Setup(n => n.GetMessageByIdAsync(new [] { id })).ReturnsAsync(messages.ToArray());

            //Act
            var result = await _notificationMessageService.GetNotificationsMessageByIds(new [] { id });

            //Assert
            Assert.NotNull(result);
            Assert.Contains(result, r => r.Id.Equals(id));
        }