public async void UsesUserFirstAndLastNameAsSubjectWhenProvided()
        {
            const int    taskSignupId = 1001;
            const int    taskId       = 12314;
            const string email        = "*****@*****.**";
            const string firstName    = "Simon";
            const string lastName     = "Says";
            const string userEmail    = "*****@*****.**";

            var mediator = new Mock <IMediator>();

            var options = new Mock <IOptions <GeneralSettings> >();

            options.Setup(o => o.Value).Returns(new GeneralSettings {
                SiteBaseUrl = "allready.com"
            });

            var notification = new TaskSignupStatusChanged {
                SignupId = taskSignupId
            };

            var taskSignup = CreateTaskSignup(taskSignupId, taskId, email, firstName, lastName, userEmail);

            Context.TaskSignups.Add(taskSignup);
            Context.SaveChanges();

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

            mediator.Verify(x => x.SendAsync(It.Is <NotifyVolunteersCommand>(y => y.ViewModel.Subject == $"{firstName} {lastName}")));
        }
        public async void PassANotifyVolunteersCommandToTheMediatorWhenEmailIsProvided()
        {
            const int    taskSignupId = 1001;
            const int    taskId       = 12314;
            const string email        = "*****@*****.**";
            const string userMail     = "*****@*****.**";

            var mediator = new Mock <IMediator>();

            var options = new Mock <IOptions <GeneralSettings> >();

            options.Setup(o => o.Value).Returns(new GeneralSettings {
                SiteBaseUrl = "allready.com"
            });

            var notification = new TaskSignupStatusChanged {
                SignupId = taskSignupId
            };

            var context    = Context;
            var taskSignup = CreateTaskSignup(taskSignupId, taskId, email, userMail: userMail);

            context.TaskSignups.Add(taskSignup);
            context.SaveChanges();

            var target = new NotifyAdminForTaskSignupStatusChangeHandler(context, mediator.Object, options.Object);
            await target.Handle(notification);

            mediator.VerifyAll();
        }
コード例 #3
0
        public async void UsesUserFirstAndLastNameAsSubjectWhenProvided()
        {
            const int    taskSignupId = 1001;
            const int    taskId       = 12314;
            const string email        = "*****@*****.**";
            const string firstName    = "Simon";
            const string lastName     = "Says";
            const string userEmail    = "*****@*****.**";

            var mediator = new Mock <IMediator>();
            NotifyVolunteersViewModel viewModel = null;

            mediator.Setup(m => m.SendAsync(It.IsAny <NotifyVolunteersCommand>()))
            .ReturnsAsync(new Unit())
            .Callback <IAsyncRequest>(request => viewModel = ((NotifyVolunteersCommand)request).ViewModel);

            var options = new Mock <IOptions <GeneralSettings> >();

            options.Setup(o => o.Value).Returns(new GeneralSettings {
                SiteBaseUrl = "allready.com"
            });

            var notification = new TaskSignupStatusChanged {
                SignupId = taskSignupId
            };

            var context    = Context;
            var taskSignup = CreateTaskSignup(taskSignupId, taskId, email, firstName, lastName, userEmail);

            context.TaskSignups.Add(taskSignup);
            context.SaveChanges();

            var target = new NotifyAdminForTaskSignupStatusChangeHandler(context, mediator.Object, options.Object);
            await target.Handle(notification);

            mediator.VerifyAll();
            viewModel.Subject.ShouldBe($"{firstName} {lastName}");
        }
        public async void NotPassANotifyVolunteersCommandToTheMediatorWhenCampaignContactsIsNull()
        {
            const int taskSignupId = 1001;
            const int taskId       = 12314;

            var mediator = new Mock <IMediator>();
            var options  = new Mock <IOptions <GeneralSettings> >();

            var notification = new TaskSignupStatusChanged {
                SignupId = taskSignupId
            };

            var context    = Context;
            var taskSignup = CreateTaskSignupWithoutCampaignContacts(taskSignupId, taskId);

            context.TaskSignups.Add(taskSignup);
            context.SaveChanges();

            var target = new NotifyAdminForTaskSignupStatusChangeHandler(context, mediator.Object, options.Object);
            await target.Handle(notification);

            mediator.Verify(m => m.SendAsync(It.IsAny <NotifyVolunteersCommand>()), Times.Never);
        }