Installing tools
- Visual Studio 17.14.* or greater
- dotnet sdk
Check that you have the latest SDK, currently 9.0.304
If not, Install sdk
- Install Github CLI
For windows:
Note: This will also upgrade existing installations of the gh cli*
.
You can also install using choco:
- Remove older Aspire
See Upgrade your development environment for details.
Check for workloads:
Following these instructions
Use Windows Search to find the Visual Studio Installer. Choose Modify on the current version (which should now me the latest), then select Individual COmponents, and enter “aspire” in the search box. Just remove the checkmark for that, and start the install. It will then run for a minute or two, and the it will be removed. Check again that the dotnet workload list
now are empty.
How to convert an existing Api to Aspire
For documentation on this see Add Aspire to Existing-App
How to extend the NUnit constraints
NUnit has a very rich and readable constraint set. Normally you don’t need to do anything. But, there are some cases where it would be nice to be able to tweak these constraints. You can always wrap them and extend them that way, but then you lose all the other good stuff, like chaining. What is not so well known is that you can extend the existing constraints, they are **designed** to be extendable! In this post I will show how you can do that easily.
How to convert NUnit Assert.AreEqual to fluent Assert.That syntax easily
Once upon a time it was declared that an Assert statement should have constraints given as AreEqual and AreNotEqual.
Further it was declared that it should be written in the opposite way of how a developer will think, that is with the expected value first and the actual value last.
Why this was made so, is still unknown.
But we end up with tons of code like:
Assert.AreEqual("Zulu", zulu.Name);
Assert.AreEqual("Z - Zulu", zulu.Description);
Assert.AreEqual(FlagType.Signal, zulu.Sort);
Assert.AreEqual(0.7, zulu.AspectRatio);
And it is not uncommon to see the two parameters swapped, making the displayed results harder to interpret.
If we write this with the fluent syntax:
Assert.That(zulu.Name,Is.EqualTo("Zulu");
This is the new fluent notation in NUnit (new and new…. it has been around for a very long time now, at least since NUnit 2.4, and that is pretty far back in time).
But - converting from one to another is not fun. Doing this manually is a very boring task.
Enter the NUnit.Analyzers, a new set of Roslyn based analyzers with refactoring.