-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Unit Test Routes using v2.1 #64
Comments
First, and most regrettably, v2 introduced a big bug and I've delisted it from nuget. So the official version is 1.7. :( Second, see this: https://github.com/mccalltd/AttributeRouting/wiki/Using-AttributeRouting-Outside-of-Web-Projects. If updating your assembly bindings doesn't work, then let me know and I'll start digging into it. Thanks! |
Thanks for the quick response! I reverted back to v1.7, and then added the bindings to the test project's App.config but I'm still getting the same results :( |
Dang! I'll look into it tomorrow. Sorry for the problems. On Apr 20, 2012, at 8:30 PM, Rob Richardson
|
Cool, thank you! |
Weird, don't we do this in the actual unit tests as well? The actual scanning code does this:
|
Yeah. This is a weird exception. The MSDN docs say: "The exception that is thrown when the security policy requires code to be type safe and the verification process is unable to verify that the code is type safe." I'm not sure where security policy would come into play. In addition, checkout out this test, which does exactly what you are doing. Could you check out the example and let me know if your test code is different in some major way? |
Is this a medium trust or some other low trust environment? I guess I haven't deployed my app using v2 yet to my host so I am not sure if trust level is coming into play here. Is this just happening locally? |
Hey guys, |
Glad to hear it's resolved. On Apr 21, 2012, at 11:21 AM, Rob Richardson wrote:
|
Hi, I have recently encountered this same problem using VS2012
It seems to be a similar issue to what FluentMVCTesting is having: https://github.com/robdmoore/FluentMVCTesting#known-issues I resolved this by:
p.s - I have code that recreates this issue if you would like a copy. |
Thanks for the info. I'm going to have to have two versions of the AttributeRouting.MVC nuget package it seems; one for MVC3 and one for MVC4. Currently the Web API stuff references the web api packages. So ideally the MVC stuff would do similarly. |
Awesome, thanks for that (sorry for the late reply) |
Is there a workaround for this? I'm using Visual Studio 2012 Ultimate and AttributeRouting 3.5.6 MVC 4 and I still have the same issue If there's another way to load the routes into memory to be able to test them? |
I solved this by adding a binding redirect to my unit-test project configuration file (App.config):
The AttributeRouting.Web.Mvc assembly (v3.5.6) has a dependency on System.Web.Mvc version 3.0.0.0. The redirect is required if you are using a more recent version. It will most likely already be in a web project's Web.config, but not so likely in the App.config of a testing class library project. |
Is there a date for this issue to be solved? Cheers, |
When I try to initialize my routes from inside a Test Fixture within another class library, I'm seeing the following types of issues.
FIRST: If I attempt something like...
routes.MapAttributeRoutes(config =>
{
config.AddRoutesFromController(typeof(MyController));
});
...I'll get an empty route collection. If I use the Generic form of this method, I'll get the following error even though MyController definitely inherits from System.Web.Mvc.Controller:
System.Security.VerificationException : Method AttributeRouting.Web.Mvc.AttributeRoutingConfiguration.AddRoutesFromController: type argument 'Namespace.Subnamespace.MySettingsController' violates the constraint of type parameter 'T'.
SECOND: When I attempt something like....
routes.MapAttributeRoutes(config =>
{
config.ScanAssembly(typeof(MyController).Assembly);
});
...I'll again get a completely empty route collection.
*NOTE: This is my first version of AttributeRouting for which I'm writing routing unit tests so I have no idea if previous versions do or do not have this issue.
The text was updated successfully, but these errors were encountered: