Asynchronous And Parallel Programming In .Net – Part 2 – Async And Await

In my last post, I discussed why asynchronous and parallel programming is becoming increasingly more important. We also saw the difference between asynchronous and parallel programming. In this post we’re going to see when asynchronous programming should be used. I’ll also show you how previous API for asynchronous programming worked. So we can see how … 

 

Asynchronous And Parallel Programming In .Net – Part 1 – Introduction

Recently I decided to start gaining more knowledge in asynchronous and parallel programming and go deeper as I progress in my study. I intend to share my knowledge in this areas through a series of posts that I’ll publish each month. I’ll go deeper and deeper with each post into the subject of asynchronous and … 

 

.Net Exceptions Best Practices

Exception is one of those constructs that is easy to misuse. This might include not throwing exception when one should or catching the exception without a good reason. Also there is the problem of throwing the wrong exception which not only doesn’t help us, but can confuse us. On the other hand there is the … 

 

Asp.Net Core 2 Logging With Serilog And Microsoft SQL Server Sink

In this post, I’m going to describe how we can configure Serilog with Asp.Net Core 2 web and Api projects. I also configure Serilog to work with SQL Server database to store the logging information. Then I’ll write an extension method and use the built-in exception handling middleware to log exceptions in production environments. What … 

 

Policy-based Authorization Using Asp.Net Core 2 And IdentityServer4

In my previous post,  I’ve discussed how we can implement policy-based authorization to secure our API using JWT. But that wasn’t what I end-up using in production. Partly because the built-in mechanism of Asp.Net Core with JWT is not as powerful as IdentityServer4. Also I needed the single sign-on feature of  IdentityServer4. There are two … 

 

Interaction Testing With Mocks Leads To A Less Maintainable Unit Test

One of the hallmark of a good unit test is its maintainability. The test that is not maintainable is a pain and there is a higher tendency for it to be ignored. One of the mistakes in software testing is Over-specification of tests. This problem often comes with testing object interaction with a mock object when … 

 

Policy-based Authorization Using Asp.Net Core 2 And Json Web Token (JWT)

I’ve been tinkering with different options to secure the API endpoint of one of my Asp.Net Core apps. What I end up using was IdentityServer4, primarily because my app needed Single sign-on too. But for straightforward scenarios, I think IdentityServer4 is an overkill. That’s where JWT comes in, so in this post, I’m going to … 

 

Isolation Frameworks: Why FakeItEasy and NSubstitude Are Better Than Moq

I’ve been trying out different isolation frameworks lately and reading about their features and differences. In terms of feature, most constrained isolation frameworks are almost the same. But there are couple of important points about naming and readability that I think worth paying attention to. I’ve used Moq in my previous projects, but recently, I’ve … 

 

Moq: Working With SetupGet, VerifyGet, SetupSet, VerifySet, SetupProperty

Moq has a set of methods specific to stubbing and verification of properties. In this post I’m going to go over each one of them, and explain when and why to use them. I also discuss their differences and in what situation we might want to use them. Let’s assume we have an interface with … 

 

Asp.Net Core Model Binding: Controlling The Binding Source

Asp.Net Core Model Binding has a set of attributes that gives us the ability to control from what source we want to receive the binding data. In this post I’m going to go through these attributes and show how and when you can use them. Default Model Binder Behavior The default behavior of model binder …