public async Task HandleGet_Exception_TestAsync() { var id = ObjectId.GenerateNewId(); var request = new GetWoodyPlantRequest(id); var expectedPlant = new WoodyPlantDocument { Id = id }; fWoodyPlantsRepository .GetByIdAsync(Arg.Is(id), Arg.Is(default(CancellationToken))) .Returns((WoodyPlantDocument?)null); await Assert.ThrowsAsync <NotFoundException>(async() => await new WoodyPlantsRequestHandler(fWoodyPlantsRepository, fVersionRepository).Handle(request, default)); }
public async Task <WoodyPlantDetailModel> Handle(GetWoodyPlantRequest request, CancellationToken cancellationToken) { var plant = await fWoodyPlantsRepository.GetByIdAsync(request.PlantId, cancellationToken); if (plant == null) { throw new NotFoundException($"Woody plant with ID '{request.PlantId}' was not found."); } return(plant.ToDetail()); }