Exemple #1
0
        public async Task SendMessageToAssignedVolunteers()
        {
            const string expectedMessage = "This is my message for all you task peeps";
            const string expectedSubject = "This is my subject";
            var          command         = new MessageTaskVolunteersCommandAsync
            {
                Model = new MessageTaskVolunteersModel
                {
                    TaskId  = 1,
                    Message = expectedMessage,
                    Subject = expectedSubject
                }
            };

            var mediator = new Mock <IMediator>();

            var handler = new MessageTaskVolunteersCommandHandlerAsync(Context, mediator.Object);
            await handler.Handle(command);

            mediator.Verify(b => b.SendAsync(It.Is <NotifyVolunteersCommand>(notifyCommand =>
                                                                             notifyCommand.ViewModel != null &&
                                                                             notifyCommand.ViewModel.EmailMessage == expectedMessage &&
                                                                             notifyCommand.ViewModel.Subject == expectedSubject &&
                                                                             notifyCommand.ViewModel.EmailRecipients.Count == 2 &&
                                                                             notifyCommand.ViewModel.EmailRecipients.Contains("*****@*****.**") &&
                                                                             notifyCommand.ViewModel.EmailRecipients.Contains("*****@*****.**")

                                                                             )), Times.Once());
        }
        public async Task SendMessageToAssignedVolunteers()
        {
            const string expectedMessage = "This is my message for all you task peeps";
            const string expectedSubject = "This is my subject";
            var command = new MessageTaskVolunteersCommandAsync
            {
                Model = new MessageTaskVolunteersModel
                {
                    TaskId = 1,
                    Message = expectedMessage,
                    Subject = expectedSubject
                }
            };

            var mediator = new Mock<IMediator>();
            
            var handler = new MessageTaskVolunteersCommandHandlerAsync(Context, mediator.Object);
            await handler.Handle(command);

            mediator.Verify(b => b.SendAsync(It.Is<NotifyVolunteersCommand>(notifyCommand =>
                   notifyCommand.ViewModel != null &&
                   notifyCommand.ViewModel.EmailMessage == expectedMessage &&
                   notifyCommand.ViewModel.Subject == expectedSubject &&
                   notifyCommand.ViewModel.EmailRecipients.Count == 2 &&
                   notifyCommand.ViewModel.EmailRecipients.Contains("*****@*****.**") &&
                   notifyCommand.ViewModel.EmailRecipients.Contains("*****@*****.**")

            )), Times.Once());   
        }