public async Task VolunteerAcceptsTask() { var mediator = new Mock <IMediator>(); var task = Context.Tasks.First(); var user = Context.Users.First(); var command = new TaskStatusChangeCommandAsync { TaskId = task.Id, UserId = user.Id, TaskStatus = TaskStatus.Accepted }; var handler = new TaskStatusChangeHandlerAsync(Context, mediator.Object); await handler.Handle(command); var taskSignup = Context.TaskSignups.First(); mediator.Verify(b => b.PublishAsync(It.Is <TaskSignupStatusChanged>(notifyCommand => notifyCommand.SignupId == taskSignup.Id)), Times.Once()); }
public async Task VolunteerAcceptsTask() { var mediator = new Mock<IMediator>(); var task = Context.Tasks.First(); var user = Context.Users.First(); var command = new TaskStatusChangeCommandAsync { TaskId = task.Id, UserId = user.Id, TaskStatus = AllReady.Areas.Admin.Features.Tasks.TaskStatus.Accepted }; var handler = new TaskStatusChangeHandlerAsync(Context, mediator.Object); await handler.Handle(command); var taskSignup = Context.TaskSignups.First(); mediator.Verify(b => b.PublishAsync(It.Is<TaskSignupStatusChanged>(notifyCommand => notifyCommand.SignupId == taskSignup.Id)), Times.Once()); }
public async Task VolunteerAssignedTask() { var task = Context.Tasks.First(); var user = Context.Users.First(); var command = new TaskStatusChangeCommandAsync { TaskId = task.Id, UserId = user.Id, TaskStatus = TaskStatus.Assigned, TaskStatusDescription = $"Assign {task.Name} to {user.UserName}" }; await handler.Handle(command); var taskSignup = Context.TaskSignups.First(); mediator.Verify(b => b.PublishAsync(It.Is <TaskSignupStatusChanged>(notifyCommand => notifyCommand.SignupId == taskSignup.Id)), Times.Once()); taskSignup.Status.ShouldBe(command.TaskStatus.ToString()); taskSignup.Task.Id.ShouldBe(command.TaskId); taskSignup.User.Id.ShouldBe(command.UserId); taskSignup.StatusDescription.ShouldBe(command.TaskStatusDescription); }