Better assertions for your unit tests

This article is part of the  C# Advent calendar . During the event, two new articles are posted each day by authors throughout the community. Introduction Unlike many other developers, I do like unit tests. These tests have saved my professional life more than once. Without them, I would have pushed very bad mistakes to the remote codebase. As much as I like unit tests, I don't like the way assertions work in the unit testing frameworks in both xUnit and MSTest. In my opinion, the assertions do not express clearly what I want to assert and I also have to explain the correct order of arguments for Assert to new developers over and over again. For a couple of years, I started using another component for this: Fluent Assertions . In this blog post, I will show you how you can create more readable assertions using this package. Installation In order the start using the package, you have to install it from the NuGet-repository. 

Using pictures in ASP.NET MVC Core with Entity Framework Core

Using pictures in ASP.NET Core MVC is not always very straightforward. A lot of articles you find simply upload the pictures to a www-folder and use them from there. This may work if you host your own website. This approach will give problems when using a cloud service. A cloud service may terminate your deployed version and may spin up a new fresh version to replace the old one. All pictures uploaded to the www-folder will then be lost and your database will have references to resources on the file system that do not exist anymore. In this post, I will show you how to store the images in your database and use them from there. The code for this blog post can be found here . For this example, I create a simple application to upload a profile to a website. I deliberately don't pay attention to the layout of the site, because it will only distract you from the meaningful code.  I have created a regular ASP.NET Core MVC 6 application using the templates available in Visual Studio 2022.

Deploying multiple projects from one solution with Azure DevOps

If you are building a modern web application, you will often need a frontend and a web API. I always want to keep these projects apart to maintain separation of concerns but to enable easy code sharing and developer focus, I also like to keep the projects in one solution. I love to use Azure DevOps for my CI/CD work, so I want to deploy these artifacts with one pipeline. In this post, I will show you, how you can do this. I do expect some basic knowledge about setting up a build and release pipeline in Azure DevOps. Visual Studio Solution For this blog post, I created the following solution. The solution contains a web application and a WebAPI. Both projects share the Domain class library. Build pipeline The solution can be built with the classic workflow or using the new yaml templates. For this post, I use the classic editor with the template for ASP.NET Core. The default settings for the build can be used. By default, all projects will be built and all p