public void Handle_InvalidCommand_ShouldThrowValidationException() { var handler = new GetAttractionCategoryDetailQueryHandler(_mapper, _mockAttractionCategoryRepository.Object); Func <Task> func = async() => await handler.Handle(new GetAttractionCategoryDetailQuery(), CancellationToken.None); func.Should().Throw <ValidationException>().Where(e => e.Errors.Count == 1 && e.Errors.Any(x => x.Contains("Id cannot be empty"))); _mockAttractionCategoryRepository.Verify(repo => repo.GetByIdWithRelatedDataAsync(It.IsAny <Guid>()), Times.Never()); }
public async Task Handle_ValidCommand_ShouldGetTheDetails() { var handler = new GetAttractionCategoryDetailQueryHandler(_mapper, _mockAttractionCategoryRepository.Object); var command = new GetAttractionCategoryDetailQuery { Id = Guid.Parse("{3ae4e108-e2df-4893-958a-2d76ab89b9dc}") }; var attractionResult = await handler.Handle(command, CancellationToken.None); attractionResult.Should().BeOfType(typeof(AttractionCategoryDetailVm)); attractionResult.Name.Should().Be("Garden"); _mockAttractionCategoryRepository.Verify(repo => repo.GetByIdWithRelatedDataAsync(It.IsAny <Guid>()), Times.Once()); }