Exemplo n.º 1
0
        public async Task Handle_GivenInvalidTopicData_ThrowsException()
        {
            // Arrange
            var topic = new TopicDTO
            {
                Id   = 99,
                Text = "Topic_new",
            };

            var command = new UpdateTopicCommand {
                Model = topic
            };

            // Act
            var handler = new UpdateTopicCommand.UpdateTopicCommandHandler(Context);

            // Assert
            await Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None));
        }
Exemplo n.º 2
0
        public async Task Handler_GivenValidData_ShouldUpdateTopic()
        {
            // Arrange
            var topic = new TopicDTO
            {
                Id   = 1,
                Text = "Topic_new",
            };

            var command = new UpdateTopicCommand {
                Model = topic
            };

            // Act
            var handler = new UpdateTopicCommand.UpdateTopicCommandHandler(Context);
            await handler.Handle(command, CancellationToken.None);

            var entity = Context.Topics.Find(topic.Id);

            // Assert
            entity.ShouldNotBeNull();

            entity.Text.ShouldBe(command.Model.Text);
        }