public async Task Create_TaskCreated() { var userId = await CreateUser(); var columnId = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, userId, "test_board", "test_column"); var command = new Create.Command() { Task = new Create.TaskData() { ColumnId = columnId, Description = "description", Header = "header" } }; await SendAsync(command); var created = await ExecuteDbContextAsync(db => db.Tasks.SingleOrDefaultAsync(d => d.Header == command.Task.Header)); created.Should().NotBeNull(); created.Header.Should().BeEquivalentTo(command.Task.Header); created.ColumnId.Should().Be(command.Task.ColumnId); created.Description.Should().BeEquivalentTo(command.Task.Description); created.OrderNum.Should().Be(default);
public async Task List_FilterByAssignedUserId_ReturnListOfTask() { var user1Id = await CreateUser(); var user2Id = await CreateUser(); var column1Id = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, user1Id); var column2Id = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, user1Id); var task1Header = "headerAABB"; var task1Description = "desc"; await TaskTestHelper.CreateTask(ContextInjector.WriteContext, user1Id, column1Id, task1Header, task1Description); var task2Header = "header2BBCC"; var task2Description = "desc2"; await TaskTestHelper.CreateTask(ContextInjector.WriteContext, user1Id, column2Id, task2Header, task2Description); var task3Header = "header3CCDD"; var task3Description = "desc3"; await TaskTestHelper.CreateTask(ContextInjector.WriteContext, user1Id, column1Id, task3Header, task3Description, new List <Guid>() { user2Id }); var query = new List.Query(null, user2Id, null); var tasksEnvelope = await SendAsync(query); tasksEnvelope.TasksCount.Should().Be(1); tasksEnvelope.Tasks.Should().HaveCount(1); }
public async Task Edit_ChangeColumnAndOrder_ColumnAndOrderChanged() { var userId = await CreateUser(); var column1Id = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, userId); var column2Id = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, userId); var task1InFirstColumn = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column1Id, "test", "test_desc"); var task2InFirstColumn = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column1Id, "test1", "test_desc1"); var task3InFirstColumn = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column1Id, "test2", "test_desc2"); var command = new Edit.Command() { TaskId = task1InFirstColumn, Task = new Edit.TaskData() { ColumnId = column2Id } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Tasks .Include(t => t.Column) .ThenInclude(t => t.Tasks) .SingleOrDefaultAsync(d => d.Id == command.TaskId)); var oldColumn = await ExecuteDbContextAsync(db => db.Columns.Include(t => t.Tasks).SingleOrDefaultAsync(t => t.Id == column1Id)); updated.Should().NotBeNull(); updated.ColumnId.Should().Be(column2Id); updated.OrderNum.Should().Be(0); oldColumn.Tasks.Should().HaveCount(2); oldColumn.Tasks.SingleOrDefault(t => t.Id == task2InFirstColumn).OrderNum.Should().Be(0); oldColumn.Tasks.SingleOrDefault(t => t.Id == task3InFirstColumn).OrderNum.Should().Be(1); }
public async Task Edit_RemoveAssignedUsers_UsersRemoved() { var user1Id = await CreateUser("email", "name", "bio"); var user2Id = await CreateUser("email1", "name1", "bio1"); var user3Id = await CreateUser("email2", "name2", "bio2"); var columnId = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, user1Id, "test_board", "test_column"); var existingTaskId = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, user1Id, columnId, "test", "test_desc"); await TaskTestHelper.AssignUsers(ContextInjector.WriteContext, existingTaskId, new List <Guid>() { user2Id, user3Id }); var command = new Edit.Command() { TaskId = existingTaskId, Task = new Edit.TaskData() { UnAssignedUsers = new List <string>() { "email1" } } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Tasks .Include(t => t.AssignedUsers) .ThenInclude(t => t.User) .SingleOrDefaultAsync(d => d.Id == command.TaskId)); updated.Should().NotBeNull(); updated.AssignedUsers.Should().HaveCount(2); var assignedUserIds = updated.AssignedUsers.Select(t => t.UserId).ToList(); foreach (var userId in new[] { user1Id, user3Id }) { assignedUserIds.Should().Contain(userId); } }
public async Task Details_CheckNotExistingTask_ReturnException() { var userId = await CreateUser(); var columnId = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, userId); var taskId = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, columnId); var rndNotExistingGuid = Guid.NewGuid(); while (rndNotExistingGuid == taskId) { rndNotExistingGuid = Guid.NewGuid(); } var query = new Details.Query(rndNotExistingGuid); Func <Task> getTaskDetailFunc = async() => await SendAsync(query); getTaskDetailFunc.Should().Throw <RestException>(); }
public async Task Details_CheckExistingTask_ReturnTask() { var userId = await CreateUser(); var columnId = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, userId); var taskHeader = "header"; var taskDescription = "desc"; var taskId = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, columnId, taskHeader, taskDescription); var query = new Details.Query(taskId); var taskEnvelope = await SendAsync(query); taskEnvelope.Should().NotBeNull(); taskEnvelope.Task.Should().NotBeNull(); taskEnvelope.Task.Header.Should().BeEquivalentTo(taskHeader); taskEnvelope.Task.Description.Should().BeEquivalentTo(taskDescription); taskEnvelope.Task.ColumnId.Should().Be(columnId); }
public async Task Edit_ChageAllProperties_TaskEdited() { var userId = await CreateUser(); var columnId = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, userId, "test_board", "test_column"); var columnId1 = await TaskTestHelper.CreateColumn( ContextInjector.WriteContext, userId, "test_board", "test_column1"); var existingTaskId = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, columnId, "test", "test_desc"); var command = new Edit.Command() { TaskId = existingTaskId, Task = new Edit.TaskData() { ColumnId = columnId1, Description = "description", Header = "header", } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Tasks.SingleOrDefaultAsync(d => d.Id == command.TaskId)); var oldColumnWithUpdatedTask = await ExecuteDbContextAsync(db => db.Columns.Include(t => t.Tasks).SingleOrDefaultAsync(d => d.Id == columnId)); var newColumnWithUpdatedTask = await ExecuteDbContextAsync(db => db.Columns.Include(t => t.Tasks).SingleOrDefaultAsync(d => d.Id == command.Task.ColumnId)); updated.Should().NotBeNull(); updated.Header.Should().BeEquivalentTo(command.Task.Header); updated.Description.Should().BeEquivalentTo(command.Task.Description); updated.OrderNum.Should().Be(0); updated.ColumnId.Should().Be(columnId1); oldColumnWithUpdatedTask.Tasks.Should().NotContain(updated); newColumnWithUpdatedTask.Tasks.Should().Contain(updated); }
public async Task List_FilterByTaskIds_ReturnListOfTask() { var userId = await CreateUser(); var column1Id = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, userId); var column2Id = await TaskTestHelper.CreateColumn(ContextInjector.WriteContext, userId); var task1Header = "header"; var task1Description = "desc"; var task1Id = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column1Id, task1Header, task1Description); var task2Header = "header2"; var task2Description = "desc2"; var task2Id = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column2Id, task2Header, task2Description); var task3Header = "header3"; var task3Description = "desc3"; var task3Id = await TaskTestHelper.CreateTask(ContextInjector.WriteContext, userId, column1Id, task3Header, task3Description); var query = new List.Query(new List <Guid>() { task2Id, task3Id }, null, null); var tasksEnvelope = await SendAsync(query); tasksEnvelope.Should().NotBeNull(); tasksEnvelope.Tasks.Should().NotBeNull(); tasksEnvelope.TasksCount.Should().Be(2); tasksEnvelope.Tasks.Should().HaveCount(2); AssertTask(tasksEnvelope.Tasks.FirstOrDefault(t => t.Id == task2Id), task2Header, task2Description, userId, column2Id); AssertTask(tasksEnvelope.Tasks.FirstOrDefault(t => t.Id == task3Id), task3Header, task3Description, userId, column1Id); }