IPolicyViolationHandler breaks NUnit test discovery in MVC 4
Using FluentSecurity 2.1, with an MVC 4 Internet Application project, implementations of the IPolicyViolationHandler causes a TypeLoadException in the Test Output window during build. The end result is that all tests cannot be run.
Steps to reproduce, in VS 2012.4 w/ the NUnit Test Adapter extension installed:
- Create a new empty MVC 4 Internet Application project.
- Add the FluentSecuirty 2.1 NuGet package.
- Add a new class, and implement an IPolicyViolationHandler.
- Build.
- The following appears in the Test Output window:
------ Discover test started ------ NUnit 1.0.0.0 discovering tests is started Exception thrown discovering tests in D:\LocalDEV\FluentSecurityBreaksNUnit\FluentSecurityBreaksNUnit\bin\FluentSecurityBreaksNUnit.dll System.TypeLoadException: Method 'Handle' in type 'FluentSecurityBreaksNUnit.MyPolicyViolationHandler' from assembly 'FluentSecurityBreaksNUnit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Server stack trace: at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) at System.Reflection.RuntimeAssembly.GetExportedTypes() at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly) at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path) at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites) at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites) at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package) at NUnit.Core.TestSuiteBuilder.Build(TestPackage package) at NUnit.Core.SimpleTestRunner.Load(TestPackage package) at NUnit.Core.ProxyTestRunner.Load(TestPackage package) at NUnit.Core.ProxyTestRunner.Load(TestPackage package) at NUnit.Core.RemoteTestRunner.Load(TestPackage package) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NUnit.Core.TestRunner.Load(TestPackage package) at NUnit.Util.TestDomain.Load(TestPackage package) at NUnit.VisualStudio.TestAdapter.NUnitTestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink) NUnit 1.0.0.0 discovering test is finished ========== Discover test finished: 0 found (0:00:00.2189986) ==========
I think this is because FluentSecurity is currently compiled against MVC 3 only. You should be able to solve this using assembly redirects in your test project. Have a look at the following and let me know if this fixes your problem.
https://gist.github.com/jincod/3840929
Will be closing this issue unless you can confirm the issue still exists. Please let us know!
Thank-you for the follow-up.
Unfortunately, the link/info you provided did not resolve the issue.
We have had to work-around the problem by recompiling FluentSecurity ourselves, against MVC 4 references.
We do not wish to maintain a parallel FluentSecurity code base, and would greatly appreciate a permanent fix.
Regards, Dave
On Wed, Apr 16, 2014 at 1:59 AM, Kristoffer Ahl [email protected]:
Will be closing this issue unless you can confirm the issue still exists. Please let us know!
— Reply to this email directly or view it on GitHubhttps://github.com/kristofferahl/FluentSecurity/issues/75#issuecomment-40565836 .