Closed divan-9 closed 4 years ago
Thanks, I wasn't aware of AD0001
. Maybe I should add a dedicated assertion that checks if there is no AD0001
or maybe GetDiagnostics
should throw an exception in that case? What do you think about it?
You right, special exception is better solution
Do you mean that options with throwing an exception from GetDiagnostics
? That would give confidence that no exception is thrown from the analyzer.
Let's say your assertion is `NoDiagnostic("XYZ0001") - this assertion is meet even if the analyzer throws an exception but it's rather not expected behavior.
I mean the solution with specific assertion like HasNoException(source)
Another option with throwing exception from GetDiagnostic is OK to, but testing this scenario is usualy looks less expressive.
Checking exceptions in unit tests is usually result of working on reported bugs, it's not common for normal TDD cycle, but sometimes it could be helpfull.
I can try to create another pull request in a while
In case of exception in analyzer it would be reported as AD0001 diagnostic. It has no location in source tree.
Sometimes it can be useful to check absence of exception by unit test
For instance
Honestly I don't really understand why this check exists in original version, and if my solution is totally wrong just let me know.