NUnit and Dynamic Object Creation

I have had a couple of tests failing for some time that I could not fix. I came back to them today and have still not got very far. The code that fails during testing, only fails during testing and I can only guess it has something todo with the way NUnit loads the assemblies.

My problems:

ConstructorInfo constructor = systemJobType.GetConstructor(typeArray); – returns null during testing
Activator.CreateInstance(systemJobType, getConstructorArguments(node)) – returns null during testing(IEventHandler)Activator.CreateInstance(handlerType);- doesn’t return null but the cast fails during testing

The commonality in these lines is that they all use interfaces. The first two lines are trying to do the same thing in different ways, create an object that takes an interface as an argument. The use of interfaces is obvious in the second line. The interfaces are different but they are all in different assemblies to where the code is running, although they are referenced.

So im still stumped….

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s