public async void LogTheExceptionIfAnExceptionOccurs()
        {
            var mediator = new Mock<IMediator>();

            mediator.Setup(x => x.SendAsync(It.IsAny<NotifyVolunteersCommand>()))
                .Throws(new InvalidOperationException("Test Exception"));

            var logger = new Mock<ILogger<NotifyAdminForUserUnenrolls>>();
            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, logger.Object);
            await target.Handle(notification);

            logger.Verify(x => x.Log(It.IsAny<LogLevel>(),
                It.IsAny<EventId>(), It.IsAny<object>(),
                It.IsAny<InvalidOperationException>(),
                It.IsAny<Func<object, Exception, string>>()), Times.AtLeastOnce);
        }
        public async void SkipNotificationIfAdminEmailIsNotSpecified()
        {
            var mediator = new Mock<IMediator>();
            var logger = Mock.Of<ILogger<NotifyAdminForUserUnenrolls>>();

            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.Skip(1).First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, logger);
            await target.Handle(notification);

            mediator.Verify(x => x.SendAsync(It.IsAny<NotifyVolunteersCommand>()), Times.Never);
        }
        public async void SendToTheAdminEmail()
        {
            const string adminEmail = "AdminEmail";

            var taskDetailForNotificationModel = new TaskDetailForNotificationModel
            {
                Volunteer = new ApplicationUser { Email = "VolunteerEmail", PhoneNumber = "VolunteerPhoneNumber" },
                CampaignContacts = new List<CampaignContact>
                {
                    new CampaignContact
                    {
                        ContactType = (int) ContactTypes.Primary,
                        Contact = new Contact { Email = adminEmail }
                    }
                }
            };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<TaskDetailForNotificationQuery>()))
                .ReturnsAsync(taskDetailForNotificationModel);

            var options = new TestOptions<GeneralSettings>();
            options.Value.SiteBaseUrl = "localhost";

            var notification = new VolunteerSignedUpNotification
            {
                UserId = Context.Users.First().Id,
                TaskId = Context.Tasks.First().Id
            };

            var target = new NotifyAdminForSignup(Context, mediator.Object, options, null);
            await target.Handle(notification);

            mediator.Verify(x => x.SendAsync(It.Is<NotifyVolunteersCommand>(y => y.ViewModel.EmailRecipients.Contains(adminEmail))), Times.Once);
        }