This post is about writing integration tests and TestContainers. As you might know writing integration tests against the in-memory provider is a bad practice. Because it only works well with trivial solutions. Mostly because the in-memory API of IQueryProvider doesn’t match the LINQ query provider. Here’s a good article called “Avoid In-Memory Databases for Tests” …
Asp.Net Core
How to mock APIs with Binary Responses using Postman Mock Server
There are different solutions for mocking an API endpoint. Such as using Microsoft Flow or doing it manually on a sever. But Postman mock servers can be a better fit if you already use Postman for your API development. Also, the initial use of their mock server is free with some limitations which I’m going …
Upgrade to Asp.Net Core From Asp.Net MVC 5
I’m working on a project written with Asp.Net MVC 5 were I work. We intend first upgrade our class libraries to .Net Standard as much as we can. Then we make the move to Asp.Net Core. But since we have many class libraries, I’ve decide to first do a little search about what is the …
.Net Core 3 New Json API And Its Features
Until the release of .Net Core 3, the Asp.Net Core was dependent on Json.NET for its serialization. But with release of .Net Core 3, this dependency is removed and a new API is created. Not only there is no dependency on Json.Net in .Net Core 3 but also this new API is much faster than …
Dependency Injection: Conditional Resolving of Multiple Implementation of Interface
Sometimes we need to resolve a dependency but not with one implementation, but with multiple. There are couple of scenarios that calls for conditional resolving of types. Such as when using a generic class and methods with a dependency on another class. Now imagine the aforementioned class is an abstract one, and we need to …
Build UI Tree With Recursive Asp.Net Core View Component
Previous version of Asp.Net MVC had the concept of local view helpers that could contain HTML too. You see an example of this here. But this feature is removed in Asp.Net Core, but we have a better tool to do it. There might be a lot of other replacement solution for using @helper, but in …
Using Task.WhenAny And Task.WhenAll
In this post, we’re going to see when we should use Task.WhenAny and Task.WhenAll. I’m also going to explain the differences between Task.WaitAny and Task.WaitAll. Then I move on to show some example of good and bad usage of these constructs. We’re also going to see some situations such as when we need immediate processing …
Top 7 Common Async Mistakes
There are some common mistakes that one can see over and over again while reading an asynchronous code base. This mistakes range from egregious mistakes that can halt the whole process. To mistakes that create confusion and semantically incorrect code. So in this post, I’ll gather these common mistakes into a post with the top …
Asp.Net Core API: Patch Method Without Using JsonPatchDocument
Some time ago, I needed to implement a mechanism for an API to update an entity without using JsonPatchDocument. The reason was that the user of the API didn’t want to necessarily use JSON to use the patch method. But user might want to use XML, Message Pack or any other format. What I needed …