public async Task Edit_ChangeAllProperties_ColumnEdited() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var existingColumnId = await ColumnTestHelper.CreateColumn(ContextInjector.WriteContext, userId, boardId, "header", "color"); var command = new Edit.Command() { ColumnId = existingColumnId, Column = new Edit.ColumnData() { Color = "color1", Header = "header1", OrderNum = 1 } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Columns.SingleOrDefaultAsync(d => d.Id == command.ColumnId)); updated.Should().NotBeNull(); updated.Header.Should().BeEquivalentTo(command.Column.Header); updated.Color.Should().BeEquivalentTo(command.Column.Color); updated.OrderNum.Should().Be(command.Column.OrderNum); }
public async Task Create_ColumnCreated() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var command = new Create.Command() { Column = new Create.ColumnData() { Header = "header", Color = "color", BoardId = boardId } }; await SendAsync(command); var createdColumn = await ExecuteDbContextAsync(db => db.Columns.SingleOrDefaultAsync(t => t.Header.Equals(command.Column.Header))); createdColumn.Should().NotBeNull(); createdColumn.Header.Should().BeEquivalentTo(command.Column.Header); createdColumn.Color.Should().BeEquivalentTo(command.Column.Color); createdColumn.BoardId.Should().Be(command.Column.BoardId); }
public async Task Details_CheckExistingColumn_ReturnTask() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var columnHeader = "column"; var columnColor = "color"; var columnId = await ColumnTestHelper.CreateColumn(ContextInjector.WriteContext, userId, boardId, columnHeader, columnColor); var query = new Details.Query(columnId); var columnEnvelope = await SendAsync(query); columnEnvelope.Should().NotBeNull(); columnEnvelope.Column.Should().NotBeNull(); columnEnvelope.Column.Header.Should().BeEquivalentTo(columnHeader); columnEnvelope.Column.Color.Should().BeEquivalentTo(columnColor); }
public async Task Details_CheckNotExistingColumn_ReturnException() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var columnId = await ColumnTestHelper.CreateColumn(ContextInjector.WriteContext, userId, boardId); var rndNotExistingGuid = Guid.NewGuid(); while (rndNotExistingGuid == columnId) { rndNotExistingGuid = Guid.NewGuid(); } var query = new Details.Query(rndNotExistingGuid); Func <Task> getColumnDetailFunc = async() => await SendAsync(query); getColumnDetailFunc.Should().Throw <RestException>(); }
public async Task Edit_AddTasks_TasksAdded() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var existingColumnId = await ColumnTestHelper.CreateColumn(ContextInjector.WriteContext, userId, boardId, "header", "color"); var tasksCount = 3; var tasks = await ColumnTestHelper.CreateTasks(ContextInjector.WriteContext, userId, existingColumnId, tasksCount); var command = new Edit.Command() { ColumnId = existingColumnId, Column = new Edit.ColumnData() { Color = "color1", Header = "header1", OrderNum = 1, AddedTasks = tasks.Select(t => t.Id).ToList() } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Columns .Include(t => t.Tasks) .SingleOrDefaultAsync(d => d.Id == command.ColumnId)); updated.Should().NotBeNull(); updated.Tasks.Should().HaveCount(tasksCount); var columnTaskIds = updated.Tasks.Select(t => t.Id).ToList(); foreach (var task in tasks) { columnTaskIds.Should().Contain(task.Id); } }
public async Task Edit_RemoveTasks_TasksRemoved() { var userId = await CreateUser(); var boardId = await ColumnTestHelper.CreateBoard(ContextInjector.WriteContext, userId); var existingColumnId = await ColumnTestHelper.CreateColumn(ContextInjector.WriteContext, userId, boardId, "header", "color"); var tasks = await ColumnTestHelper.CreateTasks(ContextInjector.WriteContext, userId, existingColumnId, 3); await ColumnTestHelper.AddTasksTo(ContextInjector.WriteContext, existingColumnId, tasks.Select(t => t.Id)); var command = new Edit.Command() { ColumnId = existingColumnId, Column = new Edit.ColumnData() { Color = "color1", Header = "header1", OrderNum = 1, RemovedTasks = new List <Guid>() { tasks[0].Id, tasks[2].Id } } }; await SendAsync(command); var updated = await ExecuteDbContextAsync(db => db.Columns .Include(t => t.Tasks) .SingleOrDefaultAsync(d => d.Id == command.ColumnId)); updated.Should().NotBeNull(); updated.Tasks.Should().HaveCount(1); updated.Tasks.Select(t => t.Id).Should().Contain(tasks[1].Id); }