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

            var board1Name = "name1";
            var board1Id   = await BoardTestHelper.CreateBoard(ContextInjector.WriteContext, userId, board1Name);

            var board2Name = "name1122";
            var board2Id   = await BoardTestHelper.CreateBoard(ContextInjector.WriteContext, userId, board2Name);

            var board3Name = "name2233";
            var board3Id   = await BoardTestHelper.CreateBoard(ContextInjector.WriteContext, userId, board3Name);

            var query          = new List.Query("2");
            var boardsEnvelope = await SendAsync(query);

            boardsEnvelope.BoardsCount.Should().Be(2);

            var board2 = boardsEnvelope.Boards.FirstOrDefault(t => t.Id == board2Id);

            board2.Should().NotBeNull();
            board2.Name.Should().BeEquivalentTo(board2Name);

            var board3 = boardsEnvelope.Boards.FirstOrDefault(t => t.Id == board3Id);

            board3.Should().NotBeNull();
            board3.Name.Should().BeEquivalentTo(board3Name);
        }
Ejemplo n.º 2
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.º 3
0
        public async Task Details_CheckExistingBoard_ReturnBoard()
        {
            var userId = await CreateUser();

            var boardName = "name";
            var boardId   = await BoardTestHelper.CreateBoard(ContextInjector.WriteContext, userId, boardName);

            var query         = new Details.Query(boardId);
            var boardEnvelope = await SendAsync(query);

            boardEnvelope.Should().NotBeNull();
            boardEnvelope.Board.Should().NotBeNull();
            boardEnvelope.Board.Name.Should().BeEquivalentTo(boardName);
            boardEnvelope.Board.OwnerId.Should().Be(userId);
        }
Ejemplo n.º 4
0
        public async Task Details_CheckNotExistingBoard_ReturnException()
        {
            var userId = await CreateUser();

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

            var rndNotExistingGuid = Guid.NewGuid();

            while (rndNotExistingGuid == boardId)
            {
                rndNotExistingGuid = Guid.NewGuid();
            }

            var         query = new Details.Query(rndNotExistingGuid);
            Func <Task> getBoardDetailFunc = async() => await SendAsync(query);

            getBoardDetailFunc.Should().Throw <RestException>();
        }
Ejemplo n.º 5
0
        public async Task Create_UseIncorrectBoardName_ReturnException()
        {
            var userId = await CreateUser();

            var boardName = "name";
            await BoardTestHelper.CreateBoard(ContextInjector.WriteContext, userId, boardName);

            var command = new Create.Command()
            {
                Board = new Create.BoardData()
                {
                    Name = boardName
                }
            };

            Func <Task> createBoardFunc = async() => await SendAsync(command);

            createBoardFunc.Should().Throw <RestException>();
        }
Ejemplo n.º 6
0
        public async Task Edit_RemoveUsers_UsersRemoved()
        {
            var user1Id = await CreateUser("email", "name", "bio");

            var user2Id = await CreateUser("email1", "name1", "bio1");

            var user3Id = await CreateUser("email2", "name2", "bio2");

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

            await BoardTestHelper.AddUserBoards(ContextInjector.WriteContext, existingBoardId,
                                                new List <Guid>() { user2Id, user3Id });

            var command = new Edit.Command()
            {
                BoardId = existingBoardId,
                Board   = new Edit.BoardData()
                {
                    RemovedUsers = new List <string>()
                    {
                        "email1"
                    }
                }
            };

            await SendAsync(command);

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

            updated.Should().NotBeNull();
            updated.UserBoards.Should().HaveCount(2);
            var userBoardIds = updated.UserBoards.Select(t => t.UserId).ToList();

            foreach (var userId in new[] { user1Id, user3Id })
            {
                userBoardIds.Should().Contain(userId);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        public async Task Edit_ChangeNameProperty_BoardEdited()
        {
            var userId = await CreateUser();

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

            var command = new Edit.Command()
            {
                BoardId = existingBoardId,
                Board   = new Edit.BoardData()
                {
                    Name = "name1"
                }
            };

            await SendAsync(command);

            var updated = await ExecuteDbContextAsync(db => db.Boards.SingleOrDefaultAsync(t => t.Id == existingBoardId));

            updated.Should().NotBeNull();
            updated.Name.Should().BeEquivalentTo(command.Board.Name);
            updated.OwnerId.Should().Be(userId);
        }