Today I Learned How to Create Custom NUnit Constraints – Part 2: Constraint Usage Syntax

In Part 1 we created a custom NUnit constraint but you where limited in using the constraint.  You could only write:

 
// Instantiate the constraint. 
Assert.That(expected, new EquivalentPropertyWiseToConstraint(actual)); 

// Matches syntax. 
Assert.That(expected, Is.Not.Matches(new EquivalentPropertyWiseToConstraint(actual)));

It would be nice to write:

// Directly access the constraint from Is.
Assert.That(expected, Is.EquivalentPropertyWiseTo(actual));

// Chain the constraint in Is.
Assert.That(expected, Is.Not.EquivalentPropertyWiseTo(actual));

To do that you should read the documentation.  End of blog post.

So is that joke still funny?  No, OK, no more.  Lets get back to what we are doing.  To access the method using Is you need to override the Is class and add a static method.  I recommended making the method name similar to your constraint name.  For example:

[Read More]

Today I Learned How to Create Custom NUnit Constraints - Part 1: Creating the Constraint

NUnit has has built in constraints for most the tests you will need to write so there is no need to create your own.  End of blog post.

OK, that was a bad joke.  The first step in creating a NUnit custom constraint is to read the documentation.  That’s it.  End of blog post.

Not as funny as the first time?  Not funny at all?  I won’t use that joke again.  But you did read the documentation right?  OK, good.

[Read More]

Today I Learned How to Run NUnit Tests for a .NET Core Project in TeamCity

In TeamCity you can’t use the usual NUnit Runner to run .NET Core unit tests.  At least I couldn’t get it to work.  I’m sure this will be fixed in the future but for now the below works for me.  I got lots of inspiration from this TeamCity blog post.

For this example I’ll use the NConstraints project.  It contains a .NET Standard project (SaturdayMP.Constraints) that we want to test and two .NET Core Test projects (SaturdayMP.Constratints.Test and TestClient).

[Read More]

Today I Learned How to Automate Objective-c Builds in TeamCity

Several months ago I discussed how to manually build an objective-c project so it can be consumed by a Xamarin Binding Project.  In this post I show how to automate the building of the objective-c project.  In my case I need to automate the building of the BEMCheckBox project but hopefully you can generalize this specific example for your own needs.

For this post I’ll assume you have a TeamCity server setup along with a TeamCity build agent on a Mac.  For help installing a TeamCity server see the official documentation.  For help installing a Mac build agent please see my previous post and/or the official documentation.

[Read More]

Today I Learned How to Install a TeamCity Build Agent on a Mac

When I was first figuring out how to port the BEMCheckBox to Xamarin I built the framework manually.  This is obviously not a good long term solution so I set about figuring out how to automate the build.  The first step was to install the TeamCity build agent on the Mac.  The official TeamCity documentation on how to do this can be found here.

First a little bit about my setup.  My TeamCity server is on a Azure virtual machine (i.e. it’s in the cloud).  My Mac build machine (Mac Book Pro) is sitting beside me in my basement office.  Some of the steps below might differ if your setup is different, such as having the TeamCity server and Mac build machine on the same network.

[Read More]