Thread affinity refers to the assignment of threads to specific processors or cores on a multi-core CPU. When a thread is bound to a specific processor or core, it is said to have affinity to that processor or core. This is in contrast to thread migration, where a thread can move between different processors or …
C#
Inheritance in Programming: Best Practices and Valid Use Cases
Inheritance is a powerful concept in programming that allows classes to inherit properties and behavior from parent classes. When used correctly, it can improve code readability, reduce redundancy, and simplify software development. However, when used incorrectly, inheritance can lead to code that is difficult to understand, maintain, and modify. Unfortunately, inheritance is often misused in …
How to use ConfigBuilders for User Secrets Management in Asp.Net MVC 5
When it comes to storing our app secrets, Asp.Net Core has a built-in mechanism to do that out of the box. But this is not the case for Asp.Net MVC 5. For MVC 5, we need to install custom configBuilders packages in order to be able to have the same functionality. There are many other …
Integration Test In Asp.Net Core 6 Using SqlServer Image and TestContainers
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” …
Enum Serialization: System.Text.Json vs Utf8Json vs Jil vs Newtonsoft
I was reading about the new System.Text.Json in .net core 3 and comparing its speed to other libraries. You can read more about it here if you’re interested. To put it shortly, the new serializer is faster then Newtonsoft but not as fast as others. Also the enum serialization between different libraries can be inconsistent. …
Careful Model Binding JavaScript ISO Date Format to DateTime
It is agreed by the .Net community that DateTime should not be used when we develop .Net applications. You can read more about why that here. In short the least we can do is to use DateTimeOffset instead. But this post is not about the common problems associated with using DateTime. But rather it’s about …
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 …
XUnit – Part 7: Categorizing Tests with xUnit Trait
Sometimes we only need to run a specific kind of tests and not others. In order to be able to do that we need some mechanism to categorize our tests. xUnit has a built in mechanism for this called Trait. In this post I’m going to show how we can use it to categorize our …
XUnit – Part 6: Testing The Database with xUnit Custom Attributes
In this Often we need to test our database code. There are a lot of ways to do that, but I think the cleanest way is to create a custom attribute for it. What we want to achieve is to create a custom attribute. In this attribute we pass the information need to connect to …
XUnit – Part 5: Share Test Context With IClassFixture and ICollectionFixture
xUnit has different mechanisms to share test context and dependencies. Not only it allows us to share different dependencies between tests, but also between multiple test classes. We can also choose to get a fresh set of data every time for our test. So in this post, I’m going to go though those mechanism with …