SPRNET-1404

Added ActionInvoker
This commit is contained in:
sbohlen
2010-12-10 19:05:03 +00:00
parent 24aa39de10
commit a8d559a426
4 changed files with 165 additions and 49 deletions

View File

@@ -1,19 +1,19 @@
#region License
/*
* Copyright © 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
/*
* Copyright © 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#endregion
@@ -41,9 +41,11 @@ namespace Spring.Web.Mvc.Tests
public class SpringControllerFactoryTests
{
private MvcApplicationContext _context;
private MvcApplicationContext _mvcNamedContext;
private SpringControllerFactory _factory;
private MvcApplicationContext _mvcNamedContext;
[SetUp]
public void _TestSetup()
{
@@ -65,16 +67,8 @@ namespace Spring.Web.Mvc.Tests
typeof(NotInContainerController),
typeof(NamedContextController),
});
}
[Test]
public void ProperlyResolvesCaseInsensitiveControllerNames()
{
IController pascalcaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
IController lowercaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "firstcontainerregistered");
Assert.AreEqual(typeof(FirstContainerRegisteredController), pascalcaseController.GetType());
Assert.AreEqual(typeof(FirstContainerRegisteredController), lowercaseController.GetType());
SpringControllerFactory.ApplicationContextName = string.Empty;
}
[Test]
@@ -84,6 +78,11 @@ namespace Spring.Web.Mvc.Tests
Assert.AreEqual("Should_Be_Matched_By_Id", ((FirstContainerRegisteredController)controller).TestValue);
}
[Test]
public void CanRetrieveControllersNotRegisteredWithContainer()
{
_factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NotInContainer");
}
[Test]
public void CanRevertToTypeMatchIfIdMatchUnsuccessful()
@@ -98,14 +97,6 @@ namespace Spring.Web.Mvc.Tests
Assert.AreEqual("Should_Be_Matched_By_Type", ((FirstContainerRegisteredController)controller).TestValue);
}
[Test]
public void CanRetrieveControllersNotRegisteredWithContainer()
{
_factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NotInContainer");
}
[Test]
public void CanUseNamedContextToResolveController()
{
@@ -114,5 +105,16 @@ namespace Spring.Web.Mvc.Tests
Assert.NotNull(controller);
}
[Test]
public void ProperlyResolvesCaseInsensitiveControllerNames()
{
IController pascalcaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "FirstContainerRegistered");
IController lowercaseController = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "firstcontainerregistered");
Assert.AreEqual(typeof(FirstContainerRegisteredController), pascalcaseController.GetType());
Assert.AreEqual(typeof(FirstContainerRegisteredController), lowercaseController.GetType());
}
}
}