public void When_EntityIsDeleted_Then_DeletedDateIsPopulated() { var template = TemplateData.GetValidTemplate(); template.Delete(); Assert.NotNull(template.DeletedAt); }
public void When_EntityIsCreated_Then_CreatedDateIsPopulated() { var currentTick = DateTime.UtcNow.Ticks; var template = TemplateData.GetValidTemplate(); Assert.NotEqual(Guid.Empty, template.Id); Assert.True(currentTick <= template.CreatedAt.Ticks); Assert.Null(template.DeletedAt); }
public async Task When_CreateNotificationWithInvalidNotificationType_Then_ThrowsNotificationTypeNotSupportedException() { const int invalidNotificationType = 99; _templateRepositoryPortMock .Setup(t => t.GetByTypeAsync((NotificationType)invalidNotificationType, It.IsAny <TemplateType>(), It.IsAny <TemplateVersion>())) .ReturnsAsync(TemplateData.GetValidTemplate()); var useCase = GetUseCase(); var request = GetValidRequest(); request.NotificationType = invalidNotificationType; await Assert.ThrowsAsync <NotificationTypeNotSupportedException>(() => useCase.ExecuteAsync(request)); _templateRepositoryPortMock.Verify(x => x.GetByTypeAsync((NotificationType)invalidNotificationType, It.IsAny <TemplateType>(), It.IsAny <TemplateVersion>()), Times.Once); _templateRenderProviderPortMock.Verify(x => x.Render(It.IsAny <string>()), Times.Once); _emailNotificationPortMock.Verify(x => x.DispatchAsync(It.IsAny <DispatchData>()), Times.Never); }
public async Task When_CreateNotification_Then_DispatchDataForReceiver() { var template = TemplateData.GetValidTemplate(); var useCase = GetUseCase(); var request = GetValidRequest(); request.TemplateMapper = TemplateMapperData.GetValidTemplateMapper(); _templateRepositoryPortMock .Setup(t => t.GetByTypeAsync(template.NotificationType, template.TemplateType, template.TemplateVersion)) .ReturnsAsync(template); _templateRenderProviderPortMock .Setup(t => t.Render(template.Content)) .ReturnsAsync(template.Content); await useCase.ExecuteAsync(request); _templateRepositoryPortMock.Verify(x => x.GetByTypeAsync((NotificationType)request.NotificationType, (TemplateType)request.TemplateType, (TemplateVersion)request.TemplateVersion), Times.Once); _templateRenderProviderPortMock.Verify(x => x.Render(It.IsAny <string>()), Times.Once); _emailNotificationPortMock.Verify(x => x.DispatchAsync(It.IsAny <DispatchData>()), Times.Once); }