Moq – Mocking a cast on an interface

moq logo

Mocking a Cast on a Mocked Interface

The Setup

var mockedInterface = new Mock<IInterface>();
mockedInterface.As().Setup(i => i.MethodOnTheInterface());

Easy as that! read more

Moq – Mocking the Request context and verifying SQLException is raised.

Mocking the Request on an API Controller

Had an API controller under unit test which made use of the HttpMessageRequest which I needed to mock.How do I get a handle on this? read more

Moq – Verifying parameter values on a mocked method call.

moq logo

Was going down a rabbit hole trying to figure out how to check param value on a mocked method (pretty simple if truth be told). read more

Nunit [ExpectedException] attribute no longer in use 3.0 onwards.

Was converting a series of unit tests from MsTest to Nunit (due to TeamCity constraints with MsTest).  Was scratching my head for a while – Coulda sworn Nunit supports the ExpectedException attribute.  Quick google and it does – Look! there in the official Nunit documentation  Further digging gets me to this  .  Ok.