From bef1d522a89abd1df867bef76fbd4f98aa0fb75a Mon Sep 17 00:00:00 2001 From: Steve Bohlen Date: Mon, 2 Feb 2015 17:56:38 -0500 Subject: [PATCH] remove unnecessary source duplication in MVC Tests and replace with source file LINKs --- .../SpringMvcDependencyResolverTests.cs | 6 +- .../Spring.Web.Mvc4.Tests.2010.csproj | 4 +- .../SpringMvcDependencyResolverTests.cs | 117 ------------------ .../Spring.Web.Mvc5.Tests.2010.csproj | 2 +- 4 files changed, 7 insertions(+), 122 deletions(-) delete mode 100644 test/Spring/Spring.Web.Mvc4.Tests/SpringMvcDependencyResolverTests.cs diff --git a/test/Spring/Spring.Web.Mvc3.Tests/SpringMvcDependencyResolverTests.cs b/test/Spring/Spring.Web.Mvc3.Tests/SpringMvcDependencyResolverTests.cs index b9a75a42..9ecf6b41 100644 --- a/test/Spring/Spring.Web.Mvc3.Tests/SpringMvcDependencyResolverTests.cs +++ b/test/Spring/Spring.Web.Mvc3.Tests/SpringMvcDependencyResolverTests.cs @@ -46,7 +46,7 @@ namespace Spring.Web.Mvc.Tests _resolver = new SpringMvcDependencyResolver(_context); - SpringMvcDependencyResolver.ApplicationContextName = string.Empty; + _resolver.ApplicationContextName = string.Empty; } #endregion @@ -58,7 +58,7 @@ namespace Spring.Web.Mvc.Tests [Test] public void CanUseNamedContextToResolveType() { - SpringMvcDependencyResolver.ApplicationContextName = "named"; + _resolver.ApplicationContextName = "named"; var service = _resolver.GetService(typeof (NamedContextController)); Assert.NotNull(service); @@ -67,7 +67,7 @@ namespace Spring.Web.Mvc.Tests [Test] public void CanUseUnnamedContextToResolveType() { - Assume.That(SpringMvcDependencyResolver.ApplicationContextName, Is.Empty, "Resolver should not have a named-context set for this test!"); + Assume.That(_resolver.ApplicationContextName, Is.Empty, "Resolver should not have a named-context set for this test!"); var service = _resolver.GetService(); Assert.NotNull(service); diff --git a/test/Spring/Spring.Web.Mvc4.Tests/Spring.Web.Mvc4.Tests.2010.csproj b/test/Spring/Spring.Web.Mvc4.Tests/Spring.Web.Mvc4.Tests.2010.csproj index 08378736..1eba37c5 100644 --- a/test/Spring/Spring.Web.Mvc4.Tests/Spring.Web.Mvc4.Tests.2010.csproj +++ b/test/Spring/Spring.Web.Mvc4.Tests/Spring.Web.Mvc4.Tests.2010.csproj @@ -122,7 +122,9 @@ Controllers\SecondContainerRegisteredController.cs - + + SpringMvcDependencyResolverTests.cs + diff --git a/test/Spring/Spring.Web.Mvc4.Tests/SpringMvcDependencyResolverTests.cs b/test/Spring/Spring.Web.Mvc4.Tests/SpringMvcDependencyResolverTests.cs deleted file mode 100644 index 0c8d6a0e..00000000 --- a/test/Spring/Spring.Web.Mvc4.Tests/SpringMvcDependencyResolverTests.cs +++ /dev/null @@ -1,117 +0,0 @@ -#region License - -/* - * Copyright © 2002-2011 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 - -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; -using NUnit.Framework; -using Spring.Context.Support; -using Spring.Web.Mvc.Tests.Controllers; - -namespace Spring.Web.Mvc.Tests -{ - [TestFixture] - public class SpringMvcDependencyResolverTests - { - #region Setup/Teardown - - [SetUp] - public void _TestSetup() - { - ContextRegistry.Clear(); - _context = new MvcApplicationContext("file://objectsMvc.xml"); - _mvcNamedContext = new MvcApplicationContext("named", false, "file://namedContextObjectsMvc.xml"); - - ContextRegistry.RegisterContext(_context); - ContextRegistry.RegisterContext(_mvcNamedContext); - - _resolver = new SpringMvcDependencyResolver(_context); - - _resolver.ApplicationContextName = string.Empty; - } - - #endregion - - private MvcApplicationContext _context; - private MvcApplicationContext _mvcNamedContext; - private SpringMvcDependencyResolver _resolver; - - [Test] - public void CanUseNamedContextToResolveType() - { - _resolver.ApplicationContextName = "named"; - var service = _resolver.GetService(typeof (NamedContextController)); - - Assert.NotNull(service); - } - - [Test] - public void CanUseUnnamedContextToResolveType() - { - Assume.That(_resolver.ApplicationContextName, Is.Empty, "Resolver should not have a named-context set for this test!"); - - var service = _resolver.GetService(); - Assert.NotNull(service); - } - - [Test] - public void RequestForNullTypeReturnsNull() - { - var service = _resolver.GetService(null); - Assert.That(service, Is.Null); - } - - [Test] - public void CanReturnCollectionOfTypes() - { - var services = _resolver.GetServices(); - Assert.That(services.Count(), Is.EqualTo(2)); - - foreach (var service in services) - { - Assert.That(service, Is.TypeOf(typeof(FirstContainerRegisteredController)), "Service Returned was not of the expected Type."); - } - } - - [Test] - public void RequestForSingleInstanceOfMultiplyRegisteredTypeReturnsFirstDefinition() - { - var service = _resolver.GetService(); - Assert.That(service.TestValue, Is.EqualTo("First Definition of Type")); - } - - [Test] - public void RequestForSingleUndefinedTypeReturnsNull() - { - var service = _resolver.GetService(); - Assert.That(service, Is.Null); - } - - [Test] - public void RequestForCollectionOfUndefinedTypesReturnsEmptyCollection() - { - var services = _resolver.GetServices(); - Assert.That(services, Is.Empty); - } - - } -} \ No newline at end of file diff --git a/test/Spring/Spring.Web.Mvc5.Tests/Spring.Web.Mvc5.Tests.2010.csproj b/test/Spring/Spring.Web.Mvc5.Tests/Spring.Web.Mvc5.Tests.2010.csproj index ebdfb051..fb024033 100644 --- a/test/Spring/Spring.Web.Mvc5.Tests/Spring.Web.Mvc5.Tests.2010.csproj +++ b/test/Spring/Spring.Web.Mvc5.Tests/Spring.Web.Mvc5.Tests.2010.csproj @@ -104,7 +104,7 @@ Controllers\SecondContainerRegisteredController.cs - + SpringMvcDependencyResolverTests.cs