public void GetNotificationTemplate_TemplateDoesExist_ReturnTheTemplate() { var disabledTemplates = new List <string>(); _repo.Setup(x => x.GetDisabledNotifications("organizationId", default)) .ReturnsAsync(disabledTemplates); var template = new NotificationTemplateDto(); _repo.Setup(x => x.GetNotificationTemplate("templateId", disabledTemplates, default)) .ReturnsAsync(template); var result = _sut.GetNotificationTemplate("templateId", default).Result; Assert.That(result, Is.EqualTo(template)); }
public void DeleteNotificationTemplate_Service_Fail() { // Arrange notificationTemplateService = new NotificationTemplateService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.Delete(It.IsAny <NotificationTemplate>())).Returns(false).Verifiable(); // Act var notificationTemplate = new NotificationTemplateDto(); var response = notificationTemplateService.DeleteNotificationTemplate(notificationTemplate); // Assert Assert.IsNotNull(response); Assert.IsFalse(response.Result); Assert.IsTrue(response.Notifications.HasErrors()); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>)); mockRepository.Verify(x => x.Delete(It.IsAny <NotificationTemplate>()), Times.Once); }
public static NotificationTemplate AsEntity(this NotificationTemplateDto notificationTemplateDto) { if (notificationTemplateDto == null) { return(null); } return(new NotificationTemplate { ID = notificationTemplateDto.Id, Name = notificationTemplateDto.Name, SubjectHeader = notificationTemplateDto.SubjectHeader, Body = notificationTemplateDto.Body, Created = notificationTemplateDto.Created, CreatedBy = notificationTemplateDto.CreatedBy.AsEntity(), Modified = notificationTemplateDto.Modified, ModifiedBy = notificationTemplateDto.ModifiedBy.AsEntity(), IsActive = notificationTemplateDto.IsActive, IsDeleted = notificationTemplateDto.IsDeleted }); }
public T Invoke(NotificationTemplateDto notificationTemplate) { return(Execute(() => { var model = new GenericViewModel(); var serviceResult = ServiceProvider.NotificationTemplateService.UpdateNotificationTemplate(notificationTemplate); if (serviceResult == null || serviceResult.Notifications.HasErrors()) { var errorMessage = "Sorry, an unexpected error occurred."; model.Notifications.AddError(errorMessage); } else { model.Success = serviceResult.Result; } return OnComplete(model); }, this.GetType().Name)); }
public void NotificationTemplateDto_Property_Count() { var notificationTemplate = new NotificationTemplateDto(); Assert.AreEqual(10, notificationTemplate.GetType().GetProperties().Count()); }