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"

My developers toolbelt 2016

I cought a tweet a few days ago asking for your developers toolbelt, specifically on windows. And I gave a very short answer and mentioned I would blog about this:

So, this is a more elaborate answer to the developers toolbelt question. My default windows developer installation contains the following:

Continue reading "My developers toolbelt 2016"

Running Windows 10 Ubuntu Bash in Cmder

"Can you run Bash in Cmder?" - In the comments of my last post (install and run (Oh-my-) zsh on Bash on Ubuntu on Windows), I was asked whether it would be possible to run the Bash (or Zsh) also in Cmder. First I thought it was not possible, but then I got curious. After digging in a bit more it turned out that it IS, in fact, possible. And it's not difficult too.

So, since I figured out how it works, I also want to show you how you can run the Windows 10 Ubuntu Bash (and/or Zsh) in Cmder.
Continue reading "Running Windows 10 Ubuntu Bash in Cmder"