public void VolunteerAcceptsTask() { var bus = new Mock<IMediator>(); var task = Context.Tasks.First(); var user = Context.Users.First(); var command = new TaskStatusChangeCommand { TaskId = task.Id, UserId = user.Id, TaskStatus = TaskStatus.Accepted }; var handler = new TaskStatusChangeHandler(Context, bus.Object); var result = handler.Handle(command); var taskSignup = Context.TaskSignups.First(); bus.Verify(b => b.Publish(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 TaskStatusChangeCommand { TaskId = @task.Id, UserId = user.Id, TaskStatus = AllReady.Areas.Admin.Features.Tasks.TaskStatus.Accepted }; var handler = new TaskStatusChangeHandler(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 void VolunteerAcceptsTask() { var bus = new Mock <IMediator>(); var task = Context.Tasks.First(); var user = Context.Users.First(); var command = new TaskStatusChangeCommand { TaskId = task.Id, UserId = user.Id, TaskStatus = TaskStatus.Accepted }; var handler = new TaskStatusChangeHandler(Context, bus.Object); var result = handler.Handle(command); var taskSignup = Context.TaskSignups.First(); bus.Verify(b => b.Publish(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 TaskStatusChangeCommand { TaskId = @task.Id, UserId = user.Id, TaskStatus = AllReady.Areas.Admin.Features.Tasks.TaskStatus.Accepted }; var handler = new TaskStatusChangeHandler(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 TaskStatusChangeCommand { 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); }