Hi,
I'm trying to create a mock HttpContextBase for unit test.
var fakePrinciple = new GenericPrincipal(
new GenericIdentity(userId),
rolesList.ToArray());
var mockHttpContext = new Mock<HttpContextBase>();
mockHttpContext.Setup(t => t.User).Returns(fakePrinciple);
HttpContextBase mockedContext = mockHttpContext.Object;
The unit test fails at the last statement with
threw exception: System.ArgumentException: Unable to obtain public key for StrongNameKeyPair..
System.Reflection.StrongNameKeyPair.nGetPublicKey(Boolean exported, Byte[] array, String container) System.Reflection.StrongNameKeyPair.get_PublicKey() System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) Castle.DynamicProxy.ModuleScope.CreateModule(Boolean signStrongName) Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithStrongName() Castle.DynamicProxy.ModuleScope.ObtainDynamicModule(Boolean isStrongNamed) Castle.DynamicProxy.Generators.Emitters.ClassEmitter.CreateTypeBuilder(ModuleScope modulescope, String name, Type (blah blah snip)
I googled and the suggestions here don't seem to work (change RSA folder security setting etc) http://groups.google.com.br/group/castle-project-users/browse_thread/thread/85685cf32a795158
Am I correct to think that because HttpContextBase
is part of System.Web.Abstraction
, which is a signed assembly. Moq will actually attempt to sign the dynamic assembly, and fail?