Ejemplo n.º 1
0
        public async Task Edit_AddColumns_ColumnsAdded()
        {
            var userId = await CreateUser();

            var existingBoardId = await BoardTestHelper.CreateBoard(
                ContextInjector.WriteContext, userId);

            var columns =
                await BoardTestHelper.CreateColumns(ContextInjector.WriteContext, userId, existingBoardId, 3);

            var command = new Edit.Command()
            {
                BoardId = existingBoardId,
                Board   = new Edit.BoardData()
                {
                    AddedColumns = columns.Select(t => t.Id).ToList()
                }
            };

            await SendAsync(command);

            var updated = await ExecuteDbContextAsync(db => db.Boards
                                                      .Include(t => t.Columns)
                                                      .SingleOrDefaultAsync(d => d.Id == command.BoardId));

            updated.Should().NotBeNull();
            updated.Columns.Should().HaveCount(3);
            var boardColumns = updated.Columns.Select(t => t.Id).ToList();

            foreach (var column in columns)
            {
                boardColumns.Should().Contain(column.Id);
            }
        }
Ejemplo n.º 2
0
        public async Task Edit_RemoveColumns_ColumnsRemoved()
        {
            var userId = await CreateUser();

            var existingBoardId = await BoardTestHelper.CreateBoard(
                ContextInjector.WriteContext, userId);

            var columns =
                await BoardTestHelper.CreateColumns(ContextInjector.WriteContext, userId, existingBoardId, 3);

            await BoardTestHelper.AddUserBoards(ContextInjector.WriteContext, existingBoardId,
                                                columns.Select(t => t.Id));

            var command = new Edit.Command()
            {
                BoardId = existingBoardId,
                Board   = new Edit.BoardData()
                {
                    RemovedColumns = new List <Guid>()
                    {
                        columns[1].Id
                    }
                }
            };

            await SendAsync(command);

            var updated = await ExecuteDbContextAsync(db => db.Boards
                                                      .Include(t => t.Columns)
                                                      .SingleOrDefaultAsync(d => d.Id == command.BoardId));

            updated.Should().NotBeNull();
            updated.Columns.Should().HaveCount(2);
            var boardColumns = updated.Columns.Select(t => t.Id).ToList();

            foreach (var columnId in new [] { columns[0].Id, columns[0].Id })
            {
                boardColumns.Should().Contain(columnId);
            }
        }