Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 testing with csla and entity framework

In VS2010 my MSTest test run just fine.

When running in VS2012 I am getting an error. The test sets the Csla.ApplicationContext.User with a Custom Business Principal. When the EntityFramework is asked to provide a new ObjectContext I receive a SerializationException saying that my Custom Business Principal type cannot be found.

All the tests that use the EntityFramework fail when running through VS2012's test runner or Resharper7's test runner. I have tried NCrunch's test runner and they all pass.

How can I resolve this issue?

like image 774
Jamie Altizer Avatar asked Aug 22 '12 13:08

Jamie Altizer


1 Answers

I found my real issue. VS2012 runs the tests in a separate AppDomain and our data access layer loads via Reflection. Still not sure why EF requires knowledge of the principal but our solution was to reset our principal to a GenericPrincipal prior to accessing EF then placing back the original. I am still wrestling with the thought that maybe an IoC container would alleviate this issue

like image 168
Jamie Altizer Avatar answered Oct 25 '22 01:10

Jamie Altizer