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 void Setup() { var context = new VideoApiDbContext(VideoBookingsDbContextOptions); _handler = new UpdateTaskCommandHandler(context); _newConferenceId = Guid.Empty; }
public async Task Execute_ReturnsCompletedTaskOnSuccess() { var repo = new Mock <IListRepository>(); var listId = Guid.NewGuid().ToString(); var taskId = Guid.NewGuid().ToString(); var list = new List { Id = listId, Tasks = new List <Domain.Task> { new Domain.Task { Id = taskId } } }; var command = new UpdateTaskCommand { ListId = listId, TaskId = taskId }; var handler = new UpdateTaskCommandHandler(repo.Object); repo.Setup(r => r.GetById(It.IsAny <string>())).ReturnsAsync(list); var result = handler.Execute(command); await result; Assert.AreEqual(true, result.IsCompleted); }
public async Task Execute_ThrowsResourceNotFoundExceptionOnNoMatchingTask() { var repo = new Mock <IListRepository>(); var listId = Guid.NewGuid().ToString(); var taskId = Guid.NewGuid().ToString(); var list = new List { Id = listId, Tasks = new List <Domain.Task>() }; var command = new UpdateTaskCommand { ListId = listId, TaskId = taskId }; var handler = new UpdateTaskCommandHandler(repo.Object); repo.Setup(r => r.GetById(It.IsAny <string>())).ReturnsAsync(list); await Assert.ThrowsExceptionAsync <ResourceNotFoundException>(() => handler.Execute(command)); }
public UpdateTaskCommandHandlerTest() { _currentUserServiceMock.Setup(X => X.GetIdCurrentUser()).Returns(Results.Ok <int>(ConstantsAccountsCQTest.Id)); _handler = new UpdateTaskCommandHandler(_tasksRepoByAccountMock.Object, _mapperMock.Object, _currentUserServiceMock.Object); }