C#

How to run every possible combination of arguments in xUnit

If you’ve ever made a test in xUnit with something like 8+ InlineDatas and thought that there has to be a better way… Well, there is! The Xunit.Combinatorial package by Andrew Arnott allows you to specify values in multiple CombinatorialValues attributes, then will run a separate test for each possible combination of those values. It’s …

How to run every possible combination of arguments in xUnit Read More »

Using Moq to verify that an object or list was passed to a method

There is an NSubstitute counterpart to this post: How to easily match on object or list arguments with NSubstitute. Click there if you would like to see how to do this using NSubstitute. I recently had a use case where I wanted to use Moq’s It.Is to check if a model with certain properties was being …

Using Moq to verify that an object or list was passed to a method Read More »

How to unit test Serilog LogContext with TestCorrelator

I recently had a use case where I had added custom properties to the LogContext with Serilog, and I wanted to be able to test if those properties were being added as expected. As it turns out, this is actually quite easy, thanks to a library called TestCorrelator by Mitch Bodmer over at https://github.com/MitchBodmer/serilog-sinks-testcorrelator (which …

How to unit test Serilog LogContext with TestCorrelator Read More »

Scroll to Top