예제 #1
0
        public async Task DeleteBoard_NonExistingBoardTest()
        {
            // Act
            var response = await Client.DeleteAsync("/boards/101");

            await AssertResponse.BadRequestAsync(response);
        }
예제 #2
0
        public async Task GetBoard_IncludeColumnsAndCards_Test()
        {
            // Arrange
            var board   = CreateBoard();
            var column1 = AddColumn(board);

            AddCard(column1);
            AddCard(column1);
            var column2 = AddColumn(board);

            AddCard(column2);
            AddCard(column2);
            AddCard(column2);
            var column3 = AddColumn(board);

            AddCard(column3);
            AddCard(column3);
            AddCard(column3);
            AddCard(column3);

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}?include=columns,cards");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var actual  = JsonSerializer.Deserialize <Board>(data, new JsonSerializerOptions());
            var columns = actual.Columns.ToList();

            Assert.Equal(3, columns.Count());
            Assert.Equal(2, columns.First(x => x.Id == column1.Id).Cards.Count());
            Assert.Equal(3, columns.First(x => x.Id == column2.Id).Cards.Count());
            Assert.Equal(4, columns.First(x => x.Id == column3.Id).Cards.Count());
        }
예제 #3
0
        public async Task GetNonExistingBoard_Test()
        {
            // Act
            var response = await Client.GetAsync("/boards/101");

            // Assert
            await AssertResponse.NotFoundAsync(response);
        }
예제 #4
0
        public async Task DeleteColumn_NonExistingBoard_Test()
        {
            // Act
            var response = await Client.DeleteAsync($"/boards/101/columns/start");

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #5
0
        public async Task GetColumn_BoardExistButNoColumns_Test()
        {
            // Arrange
            var board = CreateBoard();

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns/start");

            // Assert
            await AssertResponse.NotFoundAsync(response);
        }
예제 #6
0
        public async Task DeleteColumn_NonExistingColumn_Test()
        {
            // Arrange
            var board = CreateBoard();

            // Act
            var response = await Client.DeleteAsync($"/boards/{board.Id}/columns/start");

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #7
0
        public async Task CreateBoard_NameRequired_Test()
        {
            // Arrange
            var board = new Board();

            // Act
            var response = await ClientPostAsync("/boards", board);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #8
0
        public async Task GetBoard_IncludeCardsWithoutColumns_Test()
        {
            // Arrange
            var board = CreateBoard();

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}?include=cards");

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #9
0
        public async Task CreateColumn_NameRequired_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = new Column();

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns", column);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #10
0
        public async Task DeleteCard_NonExistentCard_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);

            // Act
            var response = await Client.DeleteAsync($"/boards/{board.Id}/columns/{column.Id}/cards/101");

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #11
0
        public async Task CreateBoard_ClientGeneratedId_Test()
        {
            // Arrange
            var board = new Board {
                Id = 101, Name = "Test Board"
            };

            // Act
            var response = await ClientPostAsync("/boards", board);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #12
0
        public async Task CreateBoard_NonExistingBoard_Test()
        {
            // Arrange
            var column = new Column {
                Id = "Test", Name = "Test Column"
            };

            // Act
            var response = await ClientPostAsync("/boards/101/columns", column);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #13
0
        public async Task CreateCard_NonExistentColumn_Test()
        {
            // Arrange
            var board = CreateBoard();
            var card  = new Card {
                Text = "Test Card"
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns/101/cards/", card);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #14
0
        public async Task CreateCard_RequireText_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card   = new Card {
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns/{column.Id}/cards/", card);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #15
0
        public async Task DeleteColumn_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);

            // Act
            var response = await Client.DeleteAsync($"/boards/{board.Id}/columns/{column.Id}");

            // Assert
            await AssertResponse.NoContentSuccessAsync(response);

            Assert.Empty(ColumnService.GetColumns(board.Id));
        }
예제 #16
0
        public async Task CreateCard_ClientGeneratedId_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card   = new Card {
                Id = Guid.NewGuid(), Text = "Test Card"
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns/{column.Id}/cards/", card);

            // Assert
            await AssertResponse.BadRequestAsync(response);
        }
예제 #17
0
        public async Task DeleteCard_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card   = AddCard(column);

            // Act
            var response = await Client.DeleteAsync($"/boards/{board.Id}/columns/{column.Id}/cards/{card.Id}");

            // Assert
            await AssertResponse.NoContentSuccessAsync(response);

            Assert.Throws <CardNotFoundException>(() => CardService.GetCard(board.Id, column.Id, card.Id));
        }
예제 #18
0
        public async Task GetColumns_BoardExistButNoColumns_Test()
        {
            // Arrange
            var board = CreateBoard();

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var columns = JsonSerializer.Deserialize <IEnumerable <Column> >(data, new JsonSerializerOptions());

            Assert.Empty(columns);
        }
예제 #19
0
        public async Task GetExistingBoard_Test()
        {
            // Arrange
            var board = CreateBoard();

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var actual = JsonSerializer.Deserialize <Board>(data, new JsonSerializerOptions());

            Assert.Equal(board.Id, actual.Id);
            Assert.Null(actual.Columns);
        }
예제 #20
0
        public async Task GetCard_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card   = AddCard(column);

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns/{column.Id}/cards/{card.Id}");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var actual = JsonSerializer.Deserialize <Card>(data, new JsonSerializerOptions());

            Assert.Equal(card.Id, actual.Id);
        }
예제 #21
0
        public async Task CreateBoard_Test()
        {
            // Arrange
            var board = new Board {
                Name = "Test Board"
            };

            // Act
            var response = await ClientPostAsync("/boards", board);

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var createdBoard = JsonSerializer.Deserialize <Board>(data, new JsonSerializerOptions());

            Assert.NotEqual(0, createdBoard.Id);
            Assert.Equal("Test Board", createdBoard.Name);
        }
예제 #22
0
        public async Task GetColumnsTest()
        {
            // Arrange
            var board = CreateBoard();

            AddColumn(board);
            AddColumn(board);
            AddColumn(board);

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var columns = JsonSerializer.Deserialize <IEnumerable <Column> >(data, new JsonSerializerOptions());

            Assert.Equal(3, columns.Count());
        }
예제 #23
0
        public async Task CreateColumn_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = new Column {
                Name = "Test Column"
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns", column);

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var createdColumn = JsonSerializer.Deserialize <Column>(data, new JsonSerializerOptions());

            Assert.Equal(board.Id, createdColumn.BoardId);
            Assert.Equal("Test Column", createdColumn.Name);
            Assert.False(string.IsNullOrEmpty(createdColumn.Id), "Expected the Id to be set");
        }
예제 #24
0
        public async Task CreateBoard_ClientGeneratedId_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = new Column {
                Id = "Test", Name = "Test Column"
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns", column);

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var createdColumn = JsonSerializer.Deserialize <Column>(data, new JsonSerializerOptions());

            Assert.Equal(board.Id, createdColumn.BoardId);
            Assert.Equal("Test Column", createdColumn.Name);
            Assert.Equal("Test", createdColumn.Id);
        }
예제 #25
0
        public async Task GetColumn_Test()
        {
            // Arrange
            var board = CreateBoard();

            ColumnService.AddColumn(board.Id, new Column {
                Id = "Start", Name = "Start"
            });

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns/start");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var column = JsonSerializer.Deserialize <Column>(data, new JsonSerializerOptions());

            Assert.Equal(board.Id, column.BoardId);
            Assert.Equal("Start", column.Id);
        }
예제 #26
0
        public async Task GetBoards_Test()
        {
            // Arrange
            var board1 = CreateBoard();
            var board2 = CreateBoard();
            var board3 = CreateBoard();

            // Act
            var response = await Client.GetAsync("/boards");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var boards = JsonSerializer.Deserialize <IEnumerable <Board> >(data, new JsonSerializerOptions()).ToList();

            Assert.Equal(3, boards.Count());
            Assert.True(boards.Exists(x => x.Id == board1.Id));
            Assert.True(boards.Exists(x => x.Id == board2.Id));
            Assert.True(boards.Exists(x => x.Id == board3.Id));
        }
예제 #27
0
        public async Task CreateCard_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card   = new Card {
                Text = "Test Card"
            };

            // Act
            var response = await ClientPostAsync($"/boards/{board.Id}/columns/{column.Id}/cards/", card);

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var actual = JsonSerializer.Deserialize <Card>(data, new JsonSerializerOptions());

            Assert.Equal(board.Id, actual.BoardId);
            Assert.Equal(column.Id, actual.ColumnId);
            Assert.True(actual.Id != null && actual.Id != Guid.Empty);
            Assert.Equal(card.Text, actual.Text);
        }
예제 #28
0
        public async Task GetCards_Test()
        {
            // Arrange
            var board  = CreateBoard();
            var column = AddColumn(board);
            var card1  = AddCard(column);
            var card2  = AddCard(column);
            var card3  = AddCard(column);

            // Act
            var response = await Client.GetAsync($"/boards/{board.Id}/columns/{column.Id}/cards");

            // Assert
            var data = await AssertResponse.SuccessAsync(response);

            var cards = JsonSerializer.Deserialize <IEnumerable <Card> >(data, new JsonSerializerOptions()).ToList();

            Assert.Equal(3, cards.Count());
            Assert.True(cards.Exists(x => x.Id == card1.Id));
            Assert.True(cards.Exists(x => x.Id == card2.Id));
            Assert.True(cards.Exists(x => x.Id == card3.Id));
        }