How to mock HttpClient in your .NET / C# unit tests

You have a class that depends on HttpClient (or IHttpClientFactory for that matter), and want to unit test that. Since you want a unit test and not an integration test, it should not call a real http endpoint. You decide to mock out your dependency on HttpClient, and soon thereafter you got stuck. After googling ‘How to mock HttpClient’ you landed on this post. So, how would you mock HttpClient for your unit tests?

I give you the short answer right away: Continue reading “How to mock HttpClient in your .NET / C# unit tests”

How to correctly normalize strings and how to compare them (in .NET)

As a developer, you sometimes have to correctly normalize strings. Be it to do quick case-insensitive lookups, or to compare stuff. The question is, what is considered a correct normalization for these use cases? This post uses C# for the sample code, but this topic applies to all languages and environments equally.
Continue reading “How to correctly normalize strings and how to compare them (in .NET)”

Using versioning in your ASP.NET Core API

Why should you care about versioning your API? Well, writing a web API with ASP.NET Core is easy. Getting it in production also. But what happens when you have your API live, clients are out there consuming it, and the need arises to change something? This is, when you should have thought about versioning your ASP.NET Core web API. This article shows how to version a web API written using ASP.NET Core. It shows different approaches and explains the differences between them.
Continue reading “Using versioning in your ASP.NET Core API”

How to run the Babun shell in Cmder

Informatik

I want to show you how you can the Babun shell in Cmder.

From my previous blog posts you know I am a fan of Cmder on Windows. It gives me a powerful shell as a replacement of the normal cmd.exe, and it also lets me run Bash and Zsh in the Windows Subsystem for Linux (WSL).

That said, Cmder does not provide a full featured *nix shell, but an extended Windows cmd prompt. And while Bash (or Zsh) on the WSL provide with an full featured Linux shell, it has some drawbacks as it really IS a Linux environment. For example, when you install certain Node packages in your project like PhantomJS, they will bring the Linux version and executables, and you can’t run them from your normal Windows environment.

Babun is a tool, that can bridge this gap. Continue reading “How to run the Babun shell in Cmder”

English keyboard layout hints for German developers

The German keyboard layout is great. It has everything you need, including all of the umlauts, the ß and also the µ. For programming, however, the German keyboard layout is 💩: The normal braces are on 8 and 9 with shift state, just off by one from the English ones at 9 and 0, but the square and curly braces are available only on Alt Gr combos left and right from that. Also the forward and backward slashes are Shift and Alt Gr combos. You can imagine that this slows you down.

So, to be more efficient when writing code, I tried and trained myself to use an English keyboard layout. This is, what I learned. Continue reading “English keyboard layout hints for German developers”

A little design update for my blog

You may notice it, this blog has got a small design update.

The old theme was fine, but it was very… white with just a little bit of black. I decided to look out for another theme that adds a little bit of color, but still focuses on readability and cleanness.

After checking out a lot of themes, testing them and navigating around to get a gasp of the overall look & feel of different themes, I found one that pleases me and hopefully you, too: I decided to go with the official WordPress Twenty Seventeen theme and just give the color scheme a little personal touch.

If you are in the mood, please leave some feedback on how you like my new design. 😉