I have a this class called CountVulneribilitesMethod()
I am trying to write a unittest for each function of this class


I am sligthly confused how to write unit test for async callback method

PS:
Please you don’t have to mention that this is old style C#, thats just a requirement
I am not asking for exact code, just give me some steps/directions i need to do please
This isn’t quite a unit test, it is using the entire app code so more like a regression or integration test. To unit test you need to use IoC or dependency injection so that you have control when running your tests. Also, if you wrap the existing old style calls in some nice Task based stuff then you’ll be able to use all the modern patterns to think about it
TaskCompletionSource is the nice way to convert from old style invoke & callback to new style Tasks
Then in your tests you can use Moq or some other mocking library to create mock dependencies where you can control what happens
It sounds like you need to write the unit tests for WebApp and MobileApp though, since to unit test this class you are only really testing the addition of two numbers
C# devs
null reference exceptions

source