public async Task NotDispatchNotificationWhenNoContactInformation()
        {
            var mockMediator = new Mock<IMediator>();
            var mockGeneralSettings = new Mock<IOptions<GeneralSettings>>();

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 3, ItineraryId = 1 });

            mockMediator.Verify(m => m.SendAsync(It.IsAny<NotifyVolunteersCommand>()),Times.Never);
        }
Пример #2
0
        public async Task NotDispatchNotificationWhenNoContactInformation()
        {
            var mockMediator        = new Mock <IMediator>();
            var mockGeneralSettings = new Mock <IOptions <GeneralSettings> >();

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 3, ItineraryId = 1 });

            mockMediator.Verify(m => m.SendAsync(It.IsAny <NotifyVolunteersCommand>()), Times.Never);
        }
        public async Task DispatchNotificationToThePreferredEmailAddressAndPhoneNumber()
        {
            var mockMediator = new Mock<IMediator>();
            var mockGeneralSettings = new Mock<IOptions<GeneralSettings>>();
            mockGeneralSettings.SetupGet(m => m.Value).Returns(new GeneralSettings { SiteBaseUrl = string.Empty });

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 1, ItineraryId = 1 });

            mockMediator.Verify(m => m.SendAsync(It.Is<NotifyVolunteersCommand>((command) =>
                command.ViewModel.SmsRecipients.Count == 1 &&
                command.ViewModel.SmsRecipients[0] == _taskSignup.PreferredPhoneNumber &&
                command.ViewModel.EmailRecipients.Count == 1 &&
                command.ViewModel.EmailRecipients[0] == _taskSignup.PreferredEmail
            )), Times.Once);
        }
Пример #4
0
        public async Task DispatchVolunteerUnAssignedNotification()
        {
            var mockMediator        = new Mock <IMediator>();
            var mockGeneralSettings = new Mock <IOptions <GeneralSettings> >();

            mockGeneralSettings.SetupGet(m => m.Value).Returns(new GeneralSettings {
                SiteBaseUrl = "http://localhost/"
            });

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 1, ItineraryId = 1, UpdateType = UpdateType.VolnteerUnassigned });

            mockMediator.Verify(m => m.SendAsync(It.Is <NotifyVolunteersCommand>((command) =>
                                                                                 string.Equals(command.ViewModel.SmsMessage, $"You’ve been unassigned from a team for {_itineraryDate} http://localhost/v") &&
                                                                                 string.Equals(command.ViewModel.Subject, $"You've been unassigned from a team for {_itineraryDate}") &&
                                                                                 string.Equals(command.ViewModel.HtmlMessage, $"The volunteer organizer has unassigned you from a team for {_itineraryDate}. See your http://localhost/v for more information.")
                                                                                 )), Times.Once);
        }
Пример #5
0
        public async Task DispatchNotificationToTheUserEmailAddressAndPhoneNumberAsFallback()
        {
            var mockMediator        = new Mock <IMediator>();
            var mockGeneralSettings = new Mock <IOptions <GeneralSettings> >();

            mockGeneralSettings.SetupGet(m => m.Value).Returns(new GeneralSettings {
                SiteBaseUrl = string.Empty
            });

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 2, ItineraryId = 1 });

            mockMediator.Verify(m => m.SendAsync(It.Is <NotifyVolunteersCommand>((command) =>
                                                                                 command.ViewModel.SmsRecipients.Count == 1 &&
                                                                                 command.ViewModel.SmsRecipients[0] == _user.PhoneNumber &&
                                                                                 command.ViewModel.EmailRecipients.Count == 1 &&
                                                                                 command.ViewModel.EmailRecipients[0] == _user.Email
                                                                                 )), Times.Once);
        }
        public async Task DispatchVolunteerUnAssignedNotification()
        {
            var mockMediator = new Mock<IMediator>();
            var mockGeneralSettings = new Mock<IOptions<GeneralSettings>>();
            mockGeneralSettings.SetupGet(m => m.Value).Returns(new GeneralSettings { SiteBaseUrl = "http://localhost/" });

            var handler = new IntineraryVolunteerListUpdatedHandler(Context, mockMediator.Object, mockGeneralSettings.Object);
            await handler.Handle(new IntineraryVolunteerListUpdated { TaskSignupId = 1, ItineraryId = 1, UpdateType = UpdateType.VolnteerUnassigned });

            mockMediator.Verify(m => m.SendAsync(It.Is<NotifyVolunteersCommand>((command) =>
                string.Equals(command.ViewModel.SmsMessage, $"You’ve been unassigned from a team for {_itineraryDate} http://localhost/v") &&
                string.Equals(command.ViewModel.Subject, $"You've been unassigned from a team for {_itineraryDate}") &&
                string.Equals(command.ViewModel.HtmlMessage, $"The volunteer organizer has unassigned you from a team for {_itineraryDate}. See your http://localhost/v for more information.")
            )), Times.Once);
        }