public async Task Should_update_status_to_done(TaskType taskType) { const string body = "Automated Test Complete Task"; const string updatedBy = "*****@*****.**"; _newConferenceId = Guid.NewGuid(); var task = new Alert(_newConferenceId, _newConferenceId, body, taskType); await TestDataManager.SeedAlerts(new List <Alert> { task }); var command = new UpdateTaskCommand(_newConferenceId, task.Id, updatedBy); await _handler.Handle(command); List <Alert> alerts; await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions)) { alerts = await db.Tasks.Where(x => x.ConferenceId == command.ConferenceId).ToListAsync(); } var updatedAlert = alerts.First(x => x.Id == task.Id); updatedAlert.Should().NotBeNull(); updatedAlert.Status.Should().Be(TaskStatus.Done); updatedAlert.Updated.Should().NotBeNull(); updatedAlert.UpdatedBy.Should().Be(updatedBy); }
public async Task HandleInvokesUpdateTaskAsyncWithCorrectData() { var options = this.CreateNewContextOptions(); const int taskId = 1; var message = new UpdateTaskCommand { AllReadyTask = new AllReadyTask {Id = taskId} }; using (var context = new AllReadyContext(options)) { context.Tasks.Add(new AllReadyTask { Id = taskId, RequiredSkills = new List<TaskSkill> { new TaskSkill() } }); await context.SaveChangesAsync(); } using (var context = new AllReadyContext(options)) { var sut = new UpdateTaskCommandHandler(context); await sut.Handle(message); } using (var context = new AllReadyContext(options)) { var task = context.Tasks.Include(t => t.RequiredSkills).FirstOrDefault(t => t.Id == taskId); Assert.NotNull(task); Assert.Equal(task.RequiredSkills.Count, 0); } }
public async Task HandleInvokesUpdateTaskAsyncWithCorrectData() { var options = this.CreateNewContextOptions(); const int taskId = 1; var message = new UpdateTaskCommand { AllReadyTask = new AllReadyTask { Id = taskId } }; using (var context = new AllReadyContext(options)) { context.Tasks.Add(new AllReadyTask { Id = taskId, RequiredSkills = new List <TaskSkill> { new TaskSkill() } }); await context.SaveChangesAsync(); } using (var context = new AllReadyContext(options)) { var sut = new UpdateTaskCommandHandler(context); await sut.Handle(message); } using (var context = new AllReadyContext(options)) { var @task = context.Tasks.Include(t => t.RequiredSkills).FirstOrDefault(t => t.Id == taskId); Assert.NotNull(@task); Assert.Equal(@task.RequiredSkills.Count, 0); } }
public async Task Handle_UpdateExistingTask_HappyFlow() { // Arrange _tasksRepoByAccountMock.Setup(x => x.TaskExists(ConstantsAccountsCQTest.Id, _request.Id)).Returns(true); TaskDomain taskInDBMock = new TaskDomain(); _tasksRepoByAccountMock.Setup(X => X.GetTask(ConstantsAccountsCQTest.Id, _request.Id)).Returns(taskInDBMock); _mapperMock.Setup(x => x.Map(_request.Task, taskInDBMock)); Result succesSaveModifications = Results.Ok(); _tasksRepoByAccountMock.Setup(x => x.SaveModifications()).Returns(succesSaveModifications); // Act Result result = await _handler.Handle(_request, CancellationToken.None); // Assert result.IsSuccess.Should().BeTrue(); result.Should().Be(succesSaveModifications); }