I was going to add a sample code example but seeing that this is 7 years old with no feed back begs to see if anyone actually reads these and actions on them. Here's the example in case they do...
1. var result = await _exampleRepository.GetAsync(request.Id, cancellationToken);
2. return result ?? throw new NotFoundException(request.Id);
Will show as green light if the happy path has a tested but no test on the NotFoundException
In Comparison the following shows no coverage on line 4
1. var result = await _exampleRepository.GetScreenAsync(request.Id, cancellationToken);
2. if (result == null)
3. {
4. throw new NotFoundException(request.Id);
5. }
I was going to add a sample code example but seeing that this is 7 years old with no feed back begs to see if anyone actually reads these and actions on them. Here's the example in case they do...
1. var result = await _exampleRepository.GetAsync(request.Id, cancellationToken);
2. return result ?? throw new NotFoundException(request.Id);
Will show as green light if the happy path has a tested but no test on the NotFoundException
In Comparison the following shows no coverage on line 4
1. var result = await _exampleRepository.GetScreenAsync(request.Id, cancellationToken);
2. if (result == null)
3. {
4. throw new NotFoundException(request.Id);
5. }