コード例 #1
0
        public async void GivenCommandWhenTaskExistsThenAttachedSaveChangesCalled()
        {
            // Arrange
            var boardTaskEntry = new BoardTaskEntity
            {
                Id = 1
            };

            SetupCommandHandler(new List<BoardTaskEntity>
            {
                boardTaskEntry
            }, new List<BoardColumnEntity>
            {
                new BoardColumnEntity
                {
                    BoardEntity = new BoardEntity()
                }
            });

            var command = new UpdateBoardTaskCommand
            {
                BoardTask = new BoardTask
                {
                    Id = 1
                }
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockDataContext.Verify(x => x.SetModified(boardTaskEntry), Times.Once);
            mockDataContext.Verify(x => x.SaveChangesAsync(), Times.Once);
        }
コード例 #2
0
        public async void GivenCommandWhenBoardAndBoardTaskExistThenBoardTaskRemovedAndSaveChangedCalled()
        {
            // Arrange
            var boardTaskEntity = new BoardTaskEntity { Id = 1 };
            SetupCommandHandler(new List<BoardEntity>
            {
                new BoardEntity {Slug = "board-name"}
            }, new List<BoardTaskEntity> { boardTaskEntity });

            var command = new DeleteBoardTaskCommand
            {
                BoardSlug = "board-name",
                BoardTaskId = 1
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockDataContext.Verify(x => x.SaveChangesAsync(), Times.Once());
            mockDataContext.Verify(x => x.Delete(boardTaskEntity), Times.Once());
        }
コード例 #3
0
        public async void GivenCommandWhenTaskExistsButBoardColumnDoesNotThenThrowBoardColumnNotFoundException()
        {
            // Arrange
            var boardEntry = new BoardTaskEntity
            {
                Id = 1
            };

            SetupCommandHandler(new List<BoardTaskEntity>
            {
                boardEntry
            }, new List<BoardColumnEntity>());

            var command = new UpdateBoardTaskCommand
            {
                BoardTask = new BoardTask
                {
                    Id = 1
                }
            };

            // Act & Assert
            await Assert.ThrowsAsync<BoardColumnNotFoundException>(() => handler.HandleAsync(command));
        }
コード例 #4
0
        public async void GivenCommandWhenTaskExistsThenMapDtoToEntity()
        {
            // Arrange
            var boardTaskEntity = new BoardTaskEntity
            {
                Id = 1
            };
            SetupCommandHandler(new List<BoardTaskEntity>
            {
                boardTaskEntity
            }, new List<BoardColumnEntity>
            {
                new BoardColumnEntity
                {
                    BoardEntity = new BoardEntity()
                }
            });
            var command = new UpdateBoardTaskCommand
            {
                BoardTask = new BoardTask
                {
                    Id = 1
                }
            };

            // Act
            await handler.HandleAsync(command);

            // Assert
            mockMappingService.Verify(x => x.Map(It.IsAny<BoardTask>(), It.IsAny<BoardTaskEntity>()), Times.Once);
        }