Entity Framework Core allows you to drop down to raw SQL queries when working with a relational database. This can be useful, because raw SQL queries can return entity types or, starting with EF Core 2.1, query types that are part of your model, but it could also be a problem when it comes down to Unit Testing.
Although running a parallel foreach that makes async calls is a pretty usual task, I found my self in a complicated situation, when async delegate calls got in the way!
The following gist file, is a basic structure of what I was trying to do: Ask
MemoryCacheManager for an item with
AddOrGetExisting by passing a
key to find the object and a generic delegate Func
task that actually returns the object.
Read More »Thread synchronisation with SemaphoreSlim and async delegate calls
While unit testing, I came across a method in an SQL repository class that was using a raw SQL query, and along with that, SQL Server’s newid() function. Since the complicated reason behind this decision was out of scope, I had to find a way to unit test that method…
SQLite was -of course- the first approach, but any attempt to actually test the method would nevertheless fail with the exception
Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such function: newid'.'.