I use Moq for testing. This framework (along with others) uses Castle.Core to create it’s proxy instances. A problem you run into is trying to assert for specific exceptions thrown from the proxy’s constructor, as Castle likes to wrap these in a Reflection.TargetInvocationException.

In order to get the test working you need to check for the TargetInvocationException exception and promote the InnerException. I have done this a few ways in the past, but the following approach is the cleanest so far.

I have a TestBase class for all my tests, that contains a delegate that handles promoting the exception.

public class TestBase
{
    protected Action<Action> promoteCtorException = (action) =>
    {
        try
        {
            action.Invoke();
        }
        catch (TargetInvocationException ex)
        {
            if (ex.InnerException != null)
            {
                throw ex.InnerException;
            }
            throw ex;
        }
    };
}

My test is written like so.

[TestClass]
public class BaseControllerTest : TestBase
{
    private IUserManagementService userManagementService;
    private IPortalService portalService;

    [TestInitialize]
    public void Setup()
    {
        var ums = new Mock<IUserManagementService>();
        this.userManagementService = ums.Object;
        var ps = new Mock<IPortalService>();
        this.portalService = ps.Object;
    }

    [TestMethod]
    public void Ctor_WithAllDepencies_Succeeds()
    {
        var controller = new Mock<BaseController>(this.userManagementService, this.portalService);
        var proxy = controller.Object;
    }

    [TestMethod]
    [ExpectedException(typeof(ArgumentNullException))]
    public void Ctor_WithNullUserManagementService_Throws()
    {
        promoteCtorException(() => {
            var controller = new Mock<BaseController>(null, this.portalService);
            var proxy = controller.Object;
        });
    }
}