Home > CodeProject, Unit Tests > Fix to Mock.SetupAllProperties() – Not working in Moq 3.0

Fix to Mock.SetupAllProperties() – Not working in Moq 3.0

If you download the latest version of Moq, you’ll notice that the Mock.SetupAllProperties() method does not work. Try it in Debug mode and you’ll notice that the method just gets skipped.

Upon inspection, I discovered that a conditional attribute that was being applied to the method which was causing it to be skipped. I am assuming that attribute was meant to be removed but got overlooked.

Anyways, to fix it, here is what you do:

1. Download the source code for Moq and open up the file Mock.Generic.cs
2. Find the method SetupAllProperties() and remove the conditional attribute:
[Conditional("DESKTOP")]
3. Re-build and overwrite for existing Moq.dll that your project is referencing with the new one.

Cheers!

Kick It on DotNetKicks.com Shout it
  1. March 5th, 2009 at 12:34 | #1

    This has been fixed in the latest release.

  1. No trackbacks yet.