kristofferahl / FluentSecurity

Fluent Security configuration for ASP.NET MVC
MIT License
163 stars 47 forks source link

IPolicyViolationHandler cuase TypeLoadException during NUnit test discovery on an MVC 4 project #76

Closed dsbut closed 10 years ago

dsbut commented 10 years ago

Implementing the IPolicyViolationHandler in an MVC 4 project, causes a TypeLoadException in the Test output window, following a build and during NUnit test discovery. This prevents execution of unit tests.

The fix appears to be to recompile FluentSecurity against MVC 4 assemblies.

Repro Steps:

  1. In VS 2012.4 (w/ NUnit Test Adapter Extension), create a new MVC 4 internet application.
  2. Add the FluentSecurity 2.1 NuGet package.
  3. Create a new class that implements the FluentSecurity.IPolicyViolationHandler.
  4. Build.
  5. See exception in Test output window (output follows):

------ 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.5669998) ==========

dsbut commented 10 years ago

Aplologies for the duplicate issue - I didn't realize that my submission yesterday was successful.