Esempio n. 1
0
        public void Handler_GivenInvalidTopicId_ThrowsException()
        {
            // Arrange
            var invalidTopicId = 99;

            // Act
            var command = new DeleteTopicCommand {
                Id = invalidTopicId
            };
            var handler = new DeleteTopicCommand.DeleteTopicCommandHandler(Context);

            // Assert
            Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None));
        }
Esempio n. 2
0
        public async Task Handler_GivenValidTopicId_ShouldRemovePost()
        {
            // Arrange
            var validTopicId = 1;

            // Act
            var command = new DeleteTopicCommand {
                Id = validTopicId
            };
            var handler = new DeleteTopicCommand.DeleteTopicCommandHandler(Context);
            await handler.Handle(command, CancellationToken.None);

            // Assert
            var entity = Context.Topics.Find(command.Id);

            entity.ShouldBeNull();
        }