I think this happens because the SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider is using my custom IIdentity class in a different AppDomain. And therefore is unable to resolve the type because it's not in the GAC.
This is maybe a more meaningful exception:
Test method Saga.BusinessLogic.Test.MedicalData.TextView.EncounterViewListTests.GetEncounterViewList_ByPatientInt_Valid threw exception: System.TypeInitializationException: The type initializer for 'SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton' threw an exception. ---> System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Saga.Library.Security.SagaIdentity,Saga.Library, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'..
System.AppDomain.get_Evidence()
System.AppDomain.get_Evidence()
System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
System.Configuration.ClientConfigurationHost.get_ConfigPaths()
System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
System.Configuration.ConfigurationManager.GetSection(String sectionName)
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider.Init()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider..ctor()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton..cctor()
SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton.PerformDependencyInjection(Object injectionTarget)
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.PerformDependencyInjection()
This could probably be solved if you fetch all the configuration elements before creating the AppDomain.