C# – Convert a list to a dictionary

The simplest way to convert a list to a dictionary is to use the Linq ToDictionary() method: This loops through the list and uses the key/element selector lambdas you passed in to build the dictionary. In this article, I’ll go into details about how to use ToDictionary() and show how to deal with duplicate keys. … Read more

Moq – Capture parameters with Callback()

When you’re using Moq to set up a mocked method, you can use Callback() to capture the parameters passed into the mocked method: There are two main use cases for capturing parameters in a test: In this article, I’ll show examples of using Callback() in those two scenarios, and then I’ll explain some problems to … Read more