upgrade to NUnit 3.5

* upgrade nuget.exe and use single installation in build-support directory
* migrate to preferred automatic visual studio package restore mode
* fix various issues with NHibernate build configuration
* fix building of MVC projects when MVC libs not present
This commit is contained in:
Marko Lahma
2016-10-24 20:36:48 +03:00
parent ad64f00abe
commit b3d1d85426
933 changed files with 2048 additions and 5612 deletions

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following

View File

@@ -54,17 +54,15 @@ namespace Spring.Aop.Framework
object[] arguments, Type targetType, IList interceptors);
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void InstantiationWithNullMethod()
{
CreateMethodInvocation(null, this, null, null, null, GetType(), null);
Assert.Throws<ArgumentNullException>(() => CreateMethodInvocation(null, this, null, null, null, GetType(), null));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void InstantiationWithNullTarget()
{
CreateMethodInvocation(null, null, null, null, null, GetType(), null);
Assert.Throws<ArgumentNullException>(() => CreateMethodInvocation(null, null, null, null, null, GetType(), null));
}
[Test]

View File

@@ -39,10 +39,9 @@ namespace Spring.Aop.Framework.Adapter
public sealed class AfterReturningAdviceInterceptorTests
{
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void PassNullAdviceToCtor()
{
new AfterReturningAdviceInterceptor(null);
Assert.Throws<ArgumentNullException>(() => new AfterReturningAdviceInterceptor(null));
}
[Test]

View File

@@ -42,17 +42,15 @@ namespace Spring.Aop.Framework.Adapter
public sealed class ThrowsAdviceInterceptorTests
{
[Test]
[ExpectedException(typeof (ArgumentException))]
public void NoHandlerMethods()
{
new ThrowsAdviceInterceptor(new object());
Assert.Throws<ArgumentException>(() => new ThrowsAdviceInterceptor(new object()));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void PassNullAdviceToCtor()
{
new ThrowsAdviceInterceptor(null);
Assert.Throws<ArgumentNullException>(() => new ThrowsAdviceInterceptor(null));
}
[Test]
@@ -163,11 +161,10 @@ namespace Spring.Aop.Framework.Adapter
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ChokesOnHandlerWhereMultipleMethodsAreApplicable()
{
object throwsHandler = new MultipleMethodsAreApplicableThrowsHandler();
new ThrowsAdviceInterceptor(throwsHandler);
Assert.Throws<ArgumentException>(() => new ThrowsAdviceInterceptor(throwsHandler));
}
[Test]

View File

@@ -25,10 +25,8 @@ using System.Threading;
using AopAlliance.Aop;
using NUnit.Framework;
using Spring.Objects;
using AopAlliance.Intercept;
using Spring.Threading;
using Spring.Util;
#endregion
@@ -58,10 +56,9 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void CurrentProxyChokesIfNoAopProxyIsOnTheStack()
{
AopContext.CurrentProxy.ToString();
Assert.Throws<AopConfigException>(() => AopContext.CurrentProxy.ToString());
}
[Test]
@@ -79,10 +76,9 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void PopProxyWithNothingOnStack()
{
AopContext.PopProxy();
Assert.Throws<AopConfigException>(() => AopContext.PopProxy());
}
[Test(Description = "SPRNET-1158")]

View File

@@ -56,19 +56,17 @@ namespace Spring.Aop.Framework.AutoProxy
}
[Test]
[ExpectedException( typeof( ArgumentNullException ) )]
public void ThrowsOnMissingAttributeTypeList()
{
AttributeAutoProxyCreator apc = new AttributeAutoProxyCreator();
apc.PostProcessAfterInitialization( new ApcTestObject(), "testObject" );
Assert.Throws<ArgumentNullException>(() => apc.PostProcessAfterInitialization(new ApcTestObject(), "testObject"));
}
[Test]
[ExpectedException( typeof( ArgumentNullException ) )]
public void ThrowsOnAssigningNullAttributeList()
{
AttributeAutoProxyCreator apc = new AttributeAutoProxyCreator();
apc.AttributeTypes = null;
Assert.Throws<ArgumentNullException>(() => apc.AttributeTypes = null);
}
[Test]

View File

@@ -55,11 +55,10 @@ namespace Spring.Aop.Framework.AutoProxy
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ThrowsArgumentExceptionIfNoCriteriaSpecified()
{
PointcutFilteringAutoProxyCreator apc = new PointcutFilteringAutoProxyCreator();
apc.PostProcessAfterInitialization( new TestObject(), "testObject" );
Assert.Throws<ArgumentNullException>(() => apc.PostProcessAfterInitialization(new TestObject(), "testObject"));
}
}
}

View File

@@ -39,19 +39,17 @@ namespace Spring.Aop.Framework.AutoProxy
{}
[Test]
[ExpectedException( typeof( ArgumentNullException ) )]
public void ThrowsOnMissingTypeNames()
{
TypeNameAutoProxyCreator apc = new TypeNameAutoProxyCreator();
apc.PostProcessAfterInitialization( new TestObject(), "testObject" );
Assert.Throws<ArgumentNullException>(() => apc.PostProcessAfterInitialization(new TestObject(), "testObject"));
}
[Test]
[ExpectedException( typeof( ArgumentNullException ) )]
public void ThrowsOnAssigningNullTypeNames()
{
TypeNameAutoProxyCreator apc = new TypeNameAutoProxyCreator();
apc.TypeNames = null;
Assert.Throws<ArgumentNullException>(() => apc.TypeNames = null);
}
[Test]

View File

@@ -21,7 +21,7 @@
#region Imports
using System;
using System.Reflection;
using Spring.Aop.Framework;
#endregion
namespace Spring.Aop.Framework

View File

@@ -21,7 +21,7 @@
#region Imports
using System;
using System.Reflection;
using Spring.Aop.Framework;
#endregion
namespace Spring.Aop.Framework

View File

@@ -22,7 +22,6 @@
using System;
using System.Reflection;
using Spring.Aop.Framework;
#endregion

View File

@@ -21,8 +21,6 @@
#region Imports
using System;
using System.Reflection;
using Spring.Aop.Framework;
#endregion

View File

@@ -64,7 +64,7 @@ namespace Spring.Aop.Framework.DynamicProxy
* to ensure that it was used appropriately by code.
*/
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
// SystemUtils.RegisterLoadedAssemblyResolver();
@@ -322,8 +322,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(NotSupportedException)
, ExpectedMessage = "Target 'target' is null.")]
public void Does_proxy_interfacemethods_without_implementation_and_by_default_throws_NotSupportedException()
{
AdvisedSupport advised = new AdvisedSupport();
@@ -333,7 +331,7 @@ namespace Spring.Aop.Framework.DynamicProxy
ITestObject proxy = CreateProxy(advised) as ITestObject;
Assert.IsNotNull(proxy);
proxy.GetDescription();
Assert.Throws<NotSupportedException>(() => proxy.GetDescription(), "Target 'target' is null.");
}
[Test]
@@ -357,7 +355,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(ArgumentNullException), MatchType=MessageMatch.Contains, UserMessage="'target'")]
public void Does_proxy_interfacemethods_without_implementation_and_throws_ArgumentNullException_On_NullTarget()
{
DynamicInvocationTestInterceptor invocationInterceptor = new DynamicInvocationTestInterceptor();
@@ -373,12 +370,11 @@ namespace Spring.Aop.Framework.DynamicProxy
// target null, call not handled by interceptor
targetSource.Target = null;
invocationInterceptor.CallProceed = true;
proxy.GetDescription();
var ex = Assert.Throws<ArgumentNullException>(() => proxy.GetDescription());
Assert.That(ex.Message, Does.Contain("'target'"));
}
[Test]
[ExpectedException(typeof(NotSupportedException)
, ExpectedMessage = "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.")]
public void Does_proxy_interfacemethods_without_implementation_and_throws_NotSupportedException_On_Incompatible_Target()
{
DynamicInvocationTestInterceptor invocationInterceptor = new DynamicInvocationTestInterceptor();
@@ -394,19 +390,17 @@ namespace Spring.Aop.Framework.DynamicProxy
// target incompatible, call not handled by interceptor
targetSource.Target = new object();
invocationInterceptor.CallProceed = true;
proxy.GetDescription();
Assert.Throws<NotSupportedException>(() => proxy.GetDescription(), "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.");
}
[Test]
[ExpectedException(typeof(NotSupportedException)
, ExpectedMessage = "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.")]
public void NoInterceptorWithNoTarget()
{
AdvisedSupport advised = new AdvisedSupport();
advised.Interfaces = new Type[] { typeof(ITestObject) };
ITestObject to = CreateProxy(advised) as ITestObject;
to.GetDescription();
Assert.Throws<NotSupportedException>(() => to.GetDescription(), "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.");
}
[Test]
@@ -426,8 +420,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(NotSupportedException)
, ExpectedMessage = "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.")]
public void InterceptorUnhandledCallWithNoTarget()
{
AdvisedSupport advised = new AdvisedSupport();
@@ -436,7 +428,7 @@ namespace Spring.Aop.Framework.DynamicProxy
ITestObject to = CreateProxy(advised) as ITestObject;
Assert.IsNotNull(to);
to.GetDescription();
Assert.Throws<NotSupportedException>(() => to.GetDescription(), "Target 'target' of type 'System.Object' does not support methods of 'Spring.Objects.ITestObject'.");
}
[Test]
@@ -1388,14 +1380,13 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void TargetCantGetProxyByDefault()
{
NeedsToSeeProxy et = new NeedsToSeeProxy();
ProxyFactory pf1 = new ProxyFactory(et);
Assert.IsFalse(pf1.ExposeProxy);
INeedsToSeeProxy proxied = (INeedsToSeeProxy)CreateProxy(pf1);
proxied.IncrementViaProxy();
Assert.Throws<AopConfigException>(() => proxied.IncrementViaProxy());
}
#region TargetReturnsThis

View File

@@ -124,10 +124,9 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void GetAllInterfacesFromTypeWithNull()
{
AopUtils.GetAllInterfacesFromType(null);
Assert.Throws<ArgumentNullException>(() => AopUtils.GetAllInterfacesFromType(null));
}
[Test]

View File

@@ -21,8 +21,6 @@
#region Imports
using System;
using System.Reflection;
using System.Collections;
using NUnit.Framework;
using Spring.Objects;

View File

@@ -61,7 +61,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void CannotProxySealedClass()
{
SealedTestObject target = new SealedTestObject();
@@ -69,11 +68,10 @@ namespace Spring.Aop.Framework.DynamicProxy
AdvisedSupport advised = new AdvisedSupport(new Type[] { });
advised.TargetSource = mockTargetSource;
IAopProxy aop = CreateAopProxy(advised);
Assert.Throws<AopConfigException>(() => CreateAopProxy(advised));
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void CannotProxyNonPublicClass()
{
NonPublicTestObject target = new NonPublicTestObject();
@@ -81,7 +79,7 @@ namespace Spring.Aop.Framework.DynamicProxy
AdvisedSupport advised = new AdvisedSupport(new Type[] { });
advised.TargetSource = mockTargetSource;
IAopProxy aop = CreateAopProxy(advised);
Assert.Throws<AopConfigException>(() => CreateAopProxy(advised));
}
[Test]
@@ -224,15 +222,23 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(AopConfigException), ExpectedMessage="Cannot create decorator-based IAopProxy for a non visible class [Spring.Aop.Framework.DynamicProxy.AbstractAopProxyTests+InternalRefOutTestObject]")]
public override void ProxyMethodWithRefOutParametersWithStandardReflection()
{
base.ProxyMethodWithRefOutParametersWithStandardReflection();
Assert.Throws<AopConfigException>(() => ProxyMethodWithRefOutParametersWithStandardReflectionWrapped(), "Cannot create decorator-based IAopProxy for a non visible class [Spring.Aop.Framework.DynamicProxy.AbstractAopProxyTests+InternalRefOutTestObject]");
}
private void ProxyMethodWithRefOutParametersWithStandardReflectionWrapped()
{
base.ProxyMethodWithRefOutParametersWithStandardReflection();
}
[Test]
[ExpectedException(typeof(AopConfigException), ExpectedMessage="Cannot create decorator-based IAopProxy for a non visible class [Spring.Aop.Framework.DynamicProxy.AbstractAopProxyTests+InternalRefOutGenericTestObject]")]
public override void ProxyGenericMethodWithRefOutParametersWithStandardReflection()
{
Assert.Throws<AopConfigException>(() => ProxyGenericMethodWithRefOutParametersWithStandardReflectionWrapped(), "Cannot create decorator-based IAopProxy for a non visible class [Spring.Aop.Framework.DynamicProxy.AbstractAopProxyTests+InternalRefOutGenericTestObject]");
}
private void ProxyGenericMethodWithRefOutParametersWithStandardReflectionWrapped()
{
base.ProxyGenericMethodWithRefOutParametersWithStandardReflection();
}

View File

@@ -44,19 +44,17 @@ namespace Spring.Aop.Framework.DynamicProxy
}
[Test]
[ExpectedException(typeof(AopConfigException), ExpectedMessage="Cannot create IAopProxy with null ProxyConfig")]
public void NullConfig()
{
IAopProxyFactory apf = new DefaultAopProxyFactory();
apf.CreateAopProxy(null);
Assert.Throws<AopConfigException>(() => apf.CreateAopProxy(null),"Cannot create IAopProxy with null ProxyConfig" );
}
[Test]
[ExpectedException(typeof(AopConfigException), ExpectedMessage="Cannot create IAopProxy with no advisors and no target source")]
public void NoInterceptorsAndNoTarget()
{
ProxyFactory advisedSupport = new ProxyFactory(new Type[] { typeof(ITestObject) });
CreateAopProxy(advisedSupport);
Assert.Throws<AopConfigException>(() => CreateAopProxy(advisedSupport), "Cannot create IAopProxy with no advisors and no target source");
}
[Test]

View File

@@ -1,5 +1,4 @@
using System;
using NUnit.Framework;
using NUnit.Framework;
using Spring.Aop.Advice;
using Spring.Context.Support;
using Spring.Objects;

View File

@@ -22,8 +22,6 @@
using System;
using Spring.Aop.Target;
#endregion
namespace Spring.Aop.Framework.DynamicProxy

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion
@@ -40,7 +38,7 @@ namespace Spring.Aop.Framework
/// <summary>
/// The setup logic executed before the execution of this test fixture.
/// </summary>
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
}
@@ -68,7 +66,7 @@ namespace Spring.Aop.Framework
/// <summary>
/// The tear down logic executed after the entire test fixture has executed.
/// </summary>
[TestFixtureTearDown]
[OneTimeTearDown]
public void FixtureTearDown()
{
}

View File

@@ -17,7 +17,6 @@
#endregion
#region Imports
using System;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;

View File

@@ -454,24 +454,23 @@ namespace Spring.Aop.Framework
/// to be included in proxiedInterface [].
/// </summary>
[Test]
[ExpectedException(typeof(InvalidCastException))]
public void GlobalsCanAddAspectInterfaces()
{
IAddedGlobalInterface agi = (IAddedGlobalInterface)factory.GetObject("autoInvoker");
IAddedGlobalInterface agi = (IAddedGlobalInterface) factory.GetObject("autoInvoker");
Assert.IsTrue(agi.GlobalsAdded == -1);
ProxyFactoryObject pfb = (ProxyFactoryObject)factory.GetObject("&validGlobals");
ProxyFactoryObject pfb = (ProxyFactoryObject) factory.GetObject("&validGlobals");
pfb.GetObject(); // for creation
Assert.AreEqual(2, pfb.Advisors.Count, "Proxy should have 1 global and 1 explicit advisor");
Assert.AreEqual(1, pfb.Introductions.Count, "Proxy should have 1 global introduction");
agi.GlobalsAdded = ((IAdvised)agi).Introductions.Count;
agi.GlobalsAdded = ((IAdvised) agi).Introductions.Count;
Assert.IsTrue(agi.GlobalsAdded == 1);
IApplicationEventListener l = (IApplicationEventListener)factory.GetObject("validGlobals");
agi = (IAddedGlobalInterface)l;
IApplicationEventListener l = (IApplicationEventListener) factory.GetObject("validGlobals");
agi = (IAddedGlobalInterface) l;
Assert.IsTrue(agi.GlobalsAdded == -1);
agi = (IAddedGlobalInterface)factory.GetObject("test1");
Assert.Throws<InvalidCastException>(() => factory.GetObject<IAddedGlobalInterface>("test1"));
}
[Test]
@@ -542,21 +541,19 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void RemoveAdvisorWhenConfigIsFrozen()
{
ProxyFactoryObject fac = CreateFrozenProxyFactory();
fac.IsFrozen = true;
fac.RemoveAdvisor(new PointcutForVoid());
Assert.Throws<AopConfigException>(() => fac.RemoveAdvisor(new PointcutForVoid()));
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void ReplaceAdvisorWhenConfigIsFrozen()
{
ProxyFactoryObject fac = CreateFrozenProxyFactory();
fac.IsFrozen = true;
fac.ReplaceAdvisor(new PointcutForVoid(), new PointcutForVoid());
Assert.Throws<AopConfigException>(() => fac.ReplaceAdvisor(new PointcutForVoid(), new PointcutForVoid()));
}
[Test]
@@ -746,35 +743,31 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void PassNullToTheProxyInterfacesProperty()
{
ProxyFactoryObject fac = new ProxyFactoryObject();
fac.ProxyInterfaces = null;
Assert.Throws<AopConfigException>(() => fac.ProxyInterfaces = null);
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void PassClassNotInterfaceNameToTheProxyInterfacesProperty()
{
ProxyFactoryObject fac = new ProxyFactoryObject();
fac.ProxyInterfaces = new string[] { typeof(GoodCommand).FullName };
Assert.Throws<AopConfigException>(() => fac.ProxyInterfaces = new string[] { typeof(GoodCommand).FullName });
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void PassRubbishNameToTheProxyInterfacesProperty()
{
ProxyFactoryObject fac = new ProxyFactoryObject();
fac.ProxyInterfaces = new string[] { "Hey" };
Assert.Throws<AopConfigException>(() => fac.ProxyInterfaces = new string[] { "Hey" });
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void PassNullElementListToTheProxyInterfacesProperty()
{
ProxyFactoryObject fac = new ProxyFactoryObject();
fac.ProxyInterfaces = new string[] { null };
Assert.Throws<AopConfigException>(() => fac.ProxyInterfaces = new string[] { null });
}
[Test]

View File

@@ -225,26 +225,23 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void InstantiateWithNullTarget()
{
new ProxyFactory((object)null);
Assert.Throws<AopConfigException>(() => new ProxyFactory((object) null));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void AddNullInterface()
{
new ProxyFactory().AddInterface(null);
Assert.Throws<ArgumentNullException>(() => new ProxyFactory().AddInterface(null));
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void AddInterfaceWhenConfigurationIsFrozen()
{
ProxyFactory factory = new ProxyFactory();
factory.IsFrozen = true;
factory.AddInterface(typeof(ITestObject));
Assert.Throws<AopConfigException>(() => factory.AddInterface(typeof(ITestObject)));
}
[Test]
@@ -609,12 +606,11 @@ namespace Spring.Aop.Framework
}
[Test]
[ExpectedException(typeof(AopConfigException))]
public void Frozen_RemoveAdvisor()
{
ProxyFactory factory = new ProxyFactory();
factory.IsFrozen = true;
factory.RemoveAdvisor(null);
Assert.Throws<AopConfigException>(() => factory.RemoveAdvisor(null));
}
public interface IMultiProxyingTestInterface

View File

@@ -17,7 +17,9 @@
#endregion
#region Imports
using System;
#endregion
namespace Spring.Aop

View File

@@ -17,7 +17,9 @@
#endregion
#region Imports
using System;
#endregion
namespace Spring.Aop

View File

@@ -17,7 +17,6 @@
#endregion
#region Imports
using System;
using AopAlliance.Intercept;
#endregion

View File

@@ -43,18 +43,16 @@ namespace Spring.Aop.Support
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void InstantiationWithNonAttributeType()
{
new AttributeMatchMethodPointcut(GetType());
Assert.Throws<ArgumentException>(() => new AttributeMatchMethodPointcut(GetType()));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void AttributeSetterWithNonAttributeType()
{
AttributeMatchMethodPointcut cut = new AttributeMatchMethodPointcut();
cut.Attribute = GetType();
Assert.Throws<ArgumentException>(() => cut.Attribute = GetType());
}
[Test]

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
@@ -69,18 +69,16 @@ namespace Spring.Aop.Support
}
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Type [Spring.Aop.Support.DefaultIntroductionAdvisorTests] is not an interface; cannot be used in an introduction.")]
public void BailsIfInterfaceTypeIsNotAnInterface()
{
DefaultIntroductionAdvisor a = new DefaultIntroductionAdvisor(new TestIntroductionAdvice(), this.GetType());
Assert.Throws<ArgumentException>(() => new DefaultIntroductionAdvisor(new TestIntroductionAdvice(), GetType()), "Type [Spring.Aop.Support.DefaultIntroductionAdvisorTests] is not an interface; cannot be used in an introduction.");
}
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Introduction [Spring.Aop.Support.DefaultIntroductionAdvisorTests+TestIntroductionAdvice] does not implement interface 'System.ICloneable' specified in introduction advice.")]
public void IntroductionMustImplementIntroducedInterfaces()
{
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new TestIntroductionAdvice(), typeof(ICloneable));
advisor.ValidateInterfaces();
Assert.Throws<ArgumentException>(() => advisor.ValidateInterfaces(), "Introduction [Spring.Aop.Support.DefaultIntroductionAdvisorTests+TestIntroductionAdvice] does not implement interface 'System.ICloneable' specified in introduction advice.");
}
[Test]

View File

@@ -43,10 +43,9 @@ namespace Spring.Aop.Support
private static readonly DateTime EXPECTED_TIMESTAMP = new DateTime(2004,8,1);
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void testNullTarget()
{
DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(null, typeof(ITimeStamped));
Assert.Throws<ArgumentNullException>(() => new DefaultIntroductionAdvisor(null, typeof(ITimeStamped)));
}
public interface ITimeStampedIntroduction: ITimeStamped, IAdvice

View File

@@ -17,11 +17,9 @@
#endregion
#region Imports
using System;
using Spring.Aop.Framework;
using Spring.Aop.Interceptor;
using Spring.Context.Support;
using Spring.Objects;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;
@@ -40,7 +38,7 @@ namespace Spring.Aop.Support
[TestFixture]
public class RegularExpressionMethodPointcutAdvisorTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
SystemUtils.RegisterLoadedAssemblyResolver();

View File

@@ -36,10 +36,9 @@ namespace Spring.Aop.Support
public sealed class RootTypeFilterTests
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void InstantiationWithNullRootType()
public void InstantiationWithNullRootType()
{
new RootTypeFilter(null);
Assert.Throws<ArgumentNullException>(() => new RootTypeFilter(null));
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Spring.Aop.Support
/// <summary>
/// The setup logic executed before the execution of this test fixture.
/// </summary>
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
// enable (null appender) logging, to ensure that the logging code is exercised
@@ -105,28 +105,25 @@ namespace Spring.Aop.Support
Assert.IsTrue(pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type));
}
[ExpectedException(typeof(ArgumentNullException))]
[Test]
public void SetPatternToNull()
{
SdkRegularExpressionMethodPointcut pcut = new SdkRegularExpressionMethodPointcut();
pcut.Pattern = null;
Assert.Throws<ArgumentNullException>(() => pcut.Pattern = null);
}
[ExpectedException(typeof(ArgumentNullException))]
[Test]
public void SetPatternsPluralToNull()
{
SdkRegularExpressionMethodPointcut pcut = new SdkRegularExpressionMethodPointcut();
pcut.Patterns = null;
Assert.Throws<ArgumentNullException>(() => pcut.Patterns = null);
}
[ExpectedException(typeof(ArgumentNullException))]
[Test]
public void SetPatternsPluralToStringArrayWithNullValue()
{
SdkRegularExpressionMethodPointcut pcut = new SdkRegularExpressionMethodPointcut();
pcut.Patterns = new string[] { null };
Assert.Throws<ArgumentNullException>(() => pcut.Patterns = new string[] { null });
}
[Test]

View File

@@ -89,11 +89,10 @@ namespace Spring.Aop.Target
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void RejectsSwapToNull()
{
HotSwappableTargetSource source = new HotSwappableTargetSource(null);
source.Swap(null);
Assert.Throws<ArgumentNullException>(() => source.Swap(null));
}
[Test]

View File

@@ -43,7 +43,7 @@ namespace Spring.Aop.Target
/// <summary>
/// The setup logic executed before the execution of this test fixture.
/// </summary>
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
// enable (null appender) logging, just to ensure that the logging code is correct
@@ -155,11 +155,10 @@ namespace Spring.Aop.Target
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void AfterPropertiesSetWithoutTargetObjectNameBeingSet()
{
PrototypeTargetSource source = new PrototypeTargetSource();
source.AfterPropertiesSet();
Assert.Throws<ArgumentNullException>(() => source.AfterPropertiesSet());
}
}
}

View File

@@ -1,5 +1,5 @@
using NUnit.Framework;
using Spring.Aop.Target;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;
/*

View File

@@ -35,10 +35,9 @@ namespace Spring.Aop.Target
public sealed class SingletonTargetSourceTests
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void InstantiationWithNullTargetSource()
{
new SingletonTargetSource(null);
Assert.Throws<ArgumentNullException>(() => new SingletonTargetSource(null));
}
[Test]

View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Collections;

View File

@@ -34,7 +34,7 @@ namespace Spring
[TestFixture]
public sealed class AopCompilerOptionsTests : CompilerOptionsTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
AssemblyToCheck = Assembly.GetAssembly(typeof (TruePointcut));

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Reflection;
using NUnit.Framework;
@@ -36,7 +35,7 @@ namespace Spring
[TestFixture]
public sealed class AopExceptionTests : ExceptionsTest
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp ()
{
AssemblyToCheck = Assembly.GetAssembly (typeof (Spring.Aop.TruePointcut));

View File

@@ -29,7 +29,6 @@ using AopAlliance.Aop;
using NUnit.Framework;
using Spring.Aop;
using Spring.Aop.Framework;
using Spring.Aop.Support;
using Spring.Context;
using Spring.Objects.Factory;

View File

@@ -26,7 +26,6 @@ using System.Collections.Specialized;
using NUnit.Framework;
using Spring.Aop.Framework;
using Spring.Caching;
using Spring.Context;
using Spring.Context.Support;
using Spring.Objects.Factory;
@@ -105,7 +104,6 @@ namespace Spring.Aspects.Cache
/// http://jira.springframework.org/browse/SPRNET-1226
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void NoCacheKeySpecified()
{
ICache cache = new NonExpiringCache();
@@ -115,12 +113,10 @@ namespace Spring.Aspects.Cache
pf.AddAdvisors(cacheAspect);
IInventorStore store = (IInventorStore)pf.GetProxy();
IList items = store.GetAllNoCacheKey();
Assert.IsNotNull(items);
Assert.Throws<ArgumentNullException>(() => store.GetAllNoCacheKey());
}
[Test]
[ExpectedException(typeof(NoSuchObjectDefinitionException))]
public void CacheDoesNotExist()
{
//ICache cache = new NonExpiringCache();
@@ -130,11 +126,10 @@ namespace Spring.Aspects.Cache
pf.AddAdvisors(cacheAspect);
IInventorStore store = (IInventorStore)pf.GetProxy();
IList items = store.GetAll();
Assert.Throws<NoSuchObjectDefinitionException>(() => store.GetAll());
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void CacheDoesNotImplementICache()
{
context.ObjectFactory.RegisterSingleton("inventors", new Object());
@@ -143,7 +138,7 @@ namespace Spring.Aspects.Cache
pf.AddAdvisors(cacheAspect);
IInventorStore store = (IInventorStore)pf.GetProxy();
IList items = store.GetAll();
Assert.Throws<ArgumentException>(() => store.GetAll());
}
[Test(Description = "http://jira.springframework.org/browse/SPRNET-959")]

View File

@@ -22,13 +22,11 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using Common.Logging;
using Common.Logging.Simple;
using NUnit.Framework;
using Spring.Aop.Framework;
using Spring.Aspects.Exceptions;
using Spring.Expressions;
using Spring.Objects;
using Spring.Util;
@@ -170,12 +168,11 @@ namespace Spring.Aspects.Exceptions
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void LoggingTestWithBadString()
{
string logHandlerText = "on foobar name ArithmeticException log 'My Message, Method Name ' + #method.Name";
ExecuteLoggingHandler(logHandlerText, "My Message");
Assert.Throws<ArgumentException>(() => ExecuteLoggingHandler(logHandlerText, "My Message"));
}
[Test]

View File

@@ -22,7 +22,7 @@
using System;
using System.Reflection;
using System.Text;
using AopAlliance.Intercept;
using Common.Logging;
using NUnit.Framework;

View File

@@ -80,7 +80,6 @@ namespace Spring.Aspects.Validation
}
[Test]
[ExpectedException(typeof(ValidationException))]
public void TestInvalidArgument()
{
MethodInfo method = typeof(ValidationTarget).GetMethod("Save");
@@ -92,7 +91,7 @@ namespace Spring.Aspects.Validation
using (mocks.Playback())
{
advice.Before(method, new object[] { null }, new ValidationTarget());
Assert.Throws<ValidationException>(() => advice.Before(method, new object[] { null }, new ValidationTarget()));
}
}

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("Spring.Aop Tests")]
[assembly: AssemblyDescription("Unit tests for Spring.Aop assembly")]

View File

@@ -30,7 +30,6 @@
<UpgradeBackupLocation />
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\..\build\VS.Net.2010\Spring.Aop.Tests\Debug\</OutputPath>
@@ -86,9 +85,9 @@
<Reference Include="Common.Logging.Core">
<HintPath>..\..\..\packages\Common.Logging.Core.3.0.0\lib\net40\Common.Logging.Core.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.5.0\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Rhino.Mocks, Version=2.9.6.40380, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -327,5 +326,5 @@
xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2010\Spring.Aop.Tests\$(ConfigurationName)\ /y /s /q /d
xcopy "$(ProjectDir)$(TargetFileName).config" ..\..\..\..\build\VS.Net.2010\Spring.Aop.Tests\$(ConfigurationName)\ /y /s /q</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</Project>
</Project>

View File

@@ -57,7 +57,7 @@
<include name="${current.bin.dir}/Spring.Core.dll" />
<include name="${current.bin.dir}/Spring.Aop.dll" />
<include name="${current.bin.dir}/Spring.Core.Tests.dll" />
<include name="${current.bin.dir}/nunit.framework.dll"/>
<include name="${nunit.lib.dir}/nunit.framework.dll"/>
<include name="${current.bin.dir}/Rhino.Mocks.dll"/>
</references>
</csc>

View File

@@ -2,5 +2,5 @@
<packages>
<package id="Common.Logging" version="3.0.0" targetFramework="net40" />
<package id="Common.Logging.Core" version="3.0.0" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="NUnit" version="3.5.0" targetFramework="net40" />
</packages>

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#if NET_4_0
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

View File

@@ -92,17 +92,15 @@ namespace Spring.Caching
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void KeyCannotBeEmptyString()
{
att = new DerivedCacheAttribute("someName", string.Empty);
Assert.Throws<ArgumentOutOfRangeException>(() => att = new DerivedCacheAttribute("someName", string.Empty));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void KeyCannotBeNull()
{
att = new DerivedCacheAttribute("someName", null);
Assert.Throws<ArgumentNullException>(() => att = new DerivedCacheAttribute("someName", null));
}
}
}

View File

@@ -160,19 +160,17 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (InvalidOperationException))]
public void AddFail()
{
FailQueue q = new FailQueue();
q.Add(Int32.Parse("1"));
Assert.Throws<InvalidOperationException>(() => q.Add(Int32.Parse("1")));
}
[Test]
[ExpectedException(typeof (NullReferenceException))]
public void AddNPE()
{
SucceedQueue q = new SucceedQueue();
q.Add(null);
Assert.Throws<NullReferenceException>(() => q.Add(null));
}
[Test]
@@ -183,11 +181,10 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (NoElementsException))]
public void RemoveFail()
{
FailQueue q = new FailQueue();
q.Remove();
Assert.Throws<NoElementsException>(() => q.Remove());
}
[Test]
@@ -198,27 +195,24 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (NoElementsException))]
public void ElementF()
{
FailQueue q = new FailQueue();
q.Element();
Assert.Throws<NoElementsException>(() => q.Element());
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void AddAll1()
{
SucceedQueue q = new SucceedQueue();
q.AddAll(null);
Assert.Throws<ArgumentNullException>(() => q.AddAll(null));
}
[Test]
[ExpectedException(typeof (ArgumentException))]
public void AddAllSelf()
{
SucceedQueue q = new SucceedQueue();
q.AddAll(q);
Assert.Throws<ArgumentException>(() => q.AddAll(q));
}
}
}

View File

@@ -27,7 +27,6 @@ using System.Globalization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
using Rhino.Mocks;
#endregion

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion

View File

@@ -52,46 +52,40 @@ namespace Spring.Collections
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Add()
{
Set.Add (1);
Assert.Throws<NotSupportedException>(() => Set.Add(1));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void AddAll()
{
Set.AddAll (new int [] {4, 5, 6});
Assert.Throws<NotSupportedException>(() => Set.AddAll(new int[] {4, 5, 6}));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Remove()
{
Set.Remove (1);
Assert.Throws<NotSupportedException>(() => Set.Remove(1));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void RemoveAll()
{
object [] removed = new object [] {1, 3};
Set.RemoveAll (removed);
object[] removed = new object[] {1, 3};
Assert.Throws<NotSupportedException>(() => Set.RemoveAll(removed));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void RetainAll()
{
Set.RetainAll (new object [] {1, 9});
Assert.Throws<NotSupportedException>(() => Set.RetainAll(new object[] {1, 9}));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Clear()
{
Set.Clear ();
Assert.Throws<NotSupportedException>(() => Set.Clear());
}
[Test]
@@ -108,10 +102,11 @@ namespace Spring.Collections
}
[Test]
public void ContainsAll() {
Assert.IsFalse (Set.ContainsAll (new object [] {"Funk", 1, 2, 3}));
Assert.IsTrue (Set.ContainsAll (new object [] {1, 3, 2}));
}
public void ContainsAll()
{
Assert.IsFalse(Set.ContainsAll(new object[] {"Funk", 1, 2, 3}));
Assert.IsTrue(Set.ContainsAll(new object[] {1, 3, 2}));
}
[Test]
public void CopyTo() {
@@ -134,55 +129,50 @@ namespace Spring.Collections
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ClonedInstanceMustStillBeImmutable ()
public void ClonedInstanceMustStillBeImmutable()
{
ISet clone = (ISet) Set.Clone ();
clone.Add ("bad chair, bad chair");
ISet clone = (ISet) Set.Clone();
Assert.Throws<NotSupportedException>(() => clone.Add("bad chair, bad chair"));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void MinusYieldsImmutableCone ()
public void MinusYieldsImmutableCone()
{
ISet mySet = new ListSet (new int [] {1, 2});
ISet clone = Set.Minus (mySet);
Assert.IsNotNull (clone);
Assert.AreEqual (1, clone.Count);
clone.Add ("bad chair, bad chair");
ISet mySet = new ListSet(new int[] {1, 2});
ISet clone = Set.Minus(mySet);
Assert.IsNotNull(clone);
Assert.AreEqual(1, clone.Count);
Assert.Throws<NotSupportedException>(() => clone.Add("bad chair, bad chair"));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void UnionYieldsImmutableCone ()
public void UnionYieldsImmutableCone()
{
ISet mySet = new ListSet (new int [] {1, 4});
ISet clone = Set.Union (mySet);
Assert.IsNotNull (clone);
Assert.AreEqual (4, clone.Count);
clone.Add ("bad chair, bad chair");
ISet mySet = new ListSet(new int[] {1, 4});
ISet clone = Set.Union(mySet);
Assert.IsNotNull(clone);
Assert.AreEqual(4, clone.Count);
Assert.Throws<NotSupportedException>(() => clone.Add("bad chair, bad chair"));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void IntersectionYieldsImmutableCone ()
public void IntersectionYieldsImmutableCone()
{
ISet mySet = new ListSet (new int [] {1, 4});
ISet clone = Set.Intersect (mySet);
Assert.IsNotNull (clone);
Assert.AreEqual (1, clone.Count);
clone.Add ("bad chair, bad chair");
ISet mySet = new ListSet(new int[] {1, 4});
ISet clone = Set.Intersect(mySet);
Assert.IsNotNull(clone);
Assert.AreEqual(1, clone.Count);
Assert.Throws<NotSupportedException>(() => clone.Add("bad chair, bad chair"));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ExclusiveOrYieldsImmutableCone ()
public void ExclusiveOrYieldsImmutableCone()
{
ISet mySet = new ListSet (new int [] {1, 4});
ISet clone = Set.ExclusiveOr (mySet);
Assert.IsNotNull (clone);
Assert.AreEqual (3, clone.Count);
clone.Add ("bad chair, bad chair");
ISet mySet = new ListSet(new int[] {1, 4});
ISet clone = Set.ExclusiveOr(mySet);
Assert.IsNotNull(clone);
Assert.AreEqual(3, clone.Count);
Assert.Throws<NotSupportedException>(() => clone.Add("bad chair, bad chair"));
}
/// <summary>

View File

@@ -91,11 +91,10 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof(System.ArgumentOutOfRangeException))]
public void RemoveAtOnEmptyLinkedList()
{
LinkedList ll = new LinkedList();
ll.RemoveAt(0);
Assert.Throws<ArgumentOutOfRangeException>(() => ll.RemoveAt(0));
}
[Test]
@@ -113,7 +112,6 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof(System.InvalidOperationException))]
public void EnumeratorModification()
{
LinkedList ll = new LinkedList();
@@ -123,8 +121,7 @@ namespace Spring.Collections
IEnumerator ienum = ll.GetEnumerator();
Assert.IsTrue(ienum.MoveNext());
ll.RemoveAt(0);
ienum.MoveNext();
Assert.Fail("Expected enumerator to fail with InvalidOperationException");
Assert.Throws<InvalidOperationException>(() => ienum.MoveNext());
}
[Test]
@@ -187,43 +184,39 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void CopyToWithNullArray()
{
LinkedList ll = new LinkedList();
ll.Add("item1");
ll.CopyTo(null, 0);
Assert.Throws<ArgumentNullException>(() => ll.CopyTo(null, 0));
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void CopyToWithNegativeIndex()
{
LinkedList ll = new LinkedList();
ll.Add("item1");
string[] strings = new string[1];
ll.CopyTo(strings, -1);
Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, -1));
}
[Test]
[ExpectedException(typeof(ArgumentOutOfRangeException))]
public void CopyToWithIndexGreaterThanArrayLength()
{
LinkedList ll = new LinkedList();
ll.Add("item1");
string[] strings = new string[1];
ll.CopyTo(strings, 2);
Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, 2));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void CopyToWithInsufficientSizeArray()
{
LinkedList ll = new LinkedList();
ll.Add("item1");
ll.Add("item2");
string[] strings = new string[2];
ll.CopyTo(strings, 1);
Assert.Throws<ArgumentException>(() => ll.CopyTo(strings, 1));
}
[Test]

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion

View File

@@ -62,35 +62,31 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (ArgumentException))]
public void ThrowsArgumentExceptionForZeroCapacity()
{
new PriorityQueue(0);
Assert.Throws<ArgumentException>(() => new PriorityQueue(0));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void ThrowsArgumentNullExceptionForNullCollection()
{
PriorityQueue q = new PriorityQueue((ICollection) null);
Assert.Throws<ArgumentNullException>(() => new PriorityQueue((ICollection) null));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ThrowsArgumentNullExceptionForNullCollectionElements()
{
object[] ints = new object[SIZE];
PriorityQueue q = new PriorityQueue(new ArrayList(ints));
Assert.Throws<ArgumentNullException>(() => new PriorityQueue(new ArrayList(ints)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void ThrowsArgumentNullExceptionForSomeNullCollectionElements()
{
object[] ints = new object[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = i;
PriorityQueue q = new PriorityQueue(new ArrayList(ints));
Assert.Throws<ArgumentNullException>(() => new PriorityQueue(new ArrayList(ints)));
}
[Test]
@@ -150,19 +146,17 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void OfferWithNullObject()
{
PriorityQueue q = new PriorityQueue(1);
q.Offer(null);
Assert.Throws<ArgumentNullException>(() => q.Offer(null));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void AddWithNullObject()
{
PriorityQueue q = new PriorityQueue(1);
q.Add(null);
Assert.Throws<ArgumentNullException>(() => q.Add(null));
}
[Test]
@@ -174,13 +168,11 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (InvalidCastException))]
public void OfferNonComparable()
{
PriorityQueue q = new PriorityQueue(1);
q.Offer(new Object());
q.Offer(new Object());
q.Offer(new Object());
Assert.Throws<InvalidCastException>(() => q.Offer(new Object()));
}
[Test]
@@ -195,31 +187,28 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void AddAllWithNullElements()
{
PriorityQueue q = new PriorityQueue(1);
q.AddAll(null);
Assert.Throws<ArgumentNullException>(() => q.AddAll(null));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void AddAllWithCollectionWithNullElements()
{
PriorityQueue q = new PriorityQueue(SIZE);
object[] ints = new object[SIZE];
q.AddAll(new ArrayList(ints));
Assert.Throws<ArgumentNullException>(() => q.AddAll(new ArrayList(ints)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void AddAllWithCollectionWithSomeNullElements()
{
PriorityQueue q = new PriorityQueue(SIZE);
object[] ints = new object[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = i;
q.AddAll(new ArrayList(ints));
Assert.Throws<ArgumentNullException>(() => q.AddAll(new ArrayList(ints)));
}
[Test]
@@ -261,7 +250,6 @@ namespace Spring.Collections
}
[Test]
[ExpectedException(typeof (NoElementsException))]
public void Element()
{
PriorityQueue q = populatedQueue(SIZE);
@@ -270,11 +258,10 @@ namespace Spring.Collections
Assert.AreEqual(i, (q.Element()));
q.Poll();
}
q.Element();
Assert.Throws<NoElementsException>(() => q.Element());
}
[Test]
[ExpectedException(typeof (NoElementsException))]
public void Remove()
{
PriorityQueue q = populatedQueue(SIZE);
@@ -282,7 +269,7 @@ namespace Spring.Collections
{
Assert.AreEqual(i, (q.Remove()));
}
q.Remove();
Assert.Throws<NoElementsException>(() => q.Remove());
}
[Test]
@@ -409,44 +396,46 @@ namespace Spring.Collections
while (!(q.Count == 0))
Assert.AreEqual(q.Remove(), r.Remove());
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void QueueCopyToArrayWithSmallerDestinationArray()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE/2];
source.CopyTo(dest);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void QueueCopyToArrayWithIndexOutOfDestinationArrayRange()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE/2];
source.CopyTo(dest, 11);
}
[Test]
[ExpectedException(typeof(IndexOutOfRangeException))]
public void QueueCopyToArrayWithValidSizeButInvalidStartingIndex()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE];
source.CopyTo(dest, 10);
}
[Test]
public void CompleteQueueCopyToArrayWithValidSize()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE];
source.CopyTo(dest);
for ( int i = 0; i < SIZE; i++ )
{
Assert.AreEqual(source.Poll(), dest[i]);
}
}
[Test]
public void PartialQueueCopyToArrayWithValidSize()
{
[Test]
public void QueueCopyToArrayWithSmallerDestinationArray()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE / 2];
Assert.Throws<ArgumentException>(() => source.CopyTo(dest));
}
[Test]
public void QueueCopyToArrayWithIndexOutOfDestinationArrayRange()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE / 2];
Assert.Throws<ArgumentException>(() => source.CopyTo(dest, 11));
}
[Test]
public void QueueCopyToArrayWithValidSizeButInvalidStartingIndex()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE];
Assert.Throws<IndexOutOfRangeException>(() => source.CopyTo(dest, 10));
}
[Test]
public void CompleteQueueCopyToArrayWithValidSize()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE];
source.CopyTo(dest);
for (int i = 0; i < SIZE; i++)
{
Assert.AreEqual(source.Poll(), dest[i]);
}
}
[Test]
public void PartialQueueCopyToArrayWithValidSize()
{
PriorityQueue source = populatedQueue(SIZE);
object[] dest = new object[SIZE*2];
source.CopyTo(dest, SIZE / 2);

View File

@@ -20,11 +20,6 @@
#region Imports
using System;
using System.Collections;
using Spring.Collections;
using NUnit.Framework;
#endregion

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion
@@ -35,7 +33,7 @@ namespace Spring.Collections
[TestFixture]
public class SortedSetTests : SetTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void Init ()
{
SupportsNull = false;

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using NUnit.Framework;
#endregion

View File

@@ -22,7 +22,7 @@
using System;
using System.Collections;
using System.Text;
using NUnit.Framework;
#endregion

View File

@@ -21,7 +21,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using Spring.Core;
using Spring.Util;

View File

@@ -19,7 +19,7 @@
#endregion
using NUnit.Framework;
using Spring.Context.Config;
using Spring.Context.Support;
using Spring.Objects.Factory.Xml;

View File

@@ -22,7 +22,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using Spring.Context.Config;
using Spring.Context.Support;
using Spring.Example.Scannable;
using Spring.Objects.Factory;

View File

@@ -25,7 +25,6 @@ using Spring.Context.Attributes.TypeFilters;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Xml;
using Spring.Context.Support;
using Spring.Stereotype;
namespace Spring.Context.Config

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Reflection;
using NUnit.Framework;
@@ -36,7 +35,7 @@ namespace Spring.Context
[TestFixture]
public sealed class ContextExceptionTests : ExceptionsTest
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp ()
{
AssemblyToCheck = Assembly.GetAssembly (typeof (Spring.Context.ApplicationContextException));

View File

@@ -1,4 +1,3 @@
using System;
using Spring.Context.Events;
#region License

View File

@@ -18,7 +18,6 @@
#endregion
using System;
using NUnit.Framework;
namespace Spring.Context.Events

View File

@@ -40,14 +40,13 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (NoSuchMessageException))]
public void GetResolvableNullCodes()
{
IMessageSourceResolvable res = mocks.StrictMock<IMessageSourceResolvable>();
Expect.Call(res.GetCodes()).Return(null);
Expect.Call(res.DefaultMessage).Return(null);
mocks.ReplayAll();
GetMessage(res, CultureInfo.CurrentCulture);
Assert.Throws<NoSuchMessageException>(() => GetMessage(res, CultureInfo.CurrentCulture));
mocks.VerifyAll();
}
@@ -113,7 +112,6 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (NoSuchMessageException))]
public void GetMessageResolvableNoValidMessage()
{
IMessageSourceResolvable res = mocks.StrictMock<IMessageSourceResolvable>();
@@ -121,7 +119,7 @@ namespace Spring.Context.Support
Expect.Call(res.GetCodes()).Return(null);
Expect.Call(res.GetArguments()).Return(null).Repeat.AtLeastOnce();
mocks.ReplayAll();
GetMessage(res, CultureInfo.CurrentCulture);
Assert.Throws<NoSuchMessageException>(() => GetMessage(res, CultureInfo.CurrentCulture));
}
[Test]
@@ -147,10 +145,9 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageNullCode()
{
Assert.IsNull(GetMessage(null));
Assert.Throws<NoSuchMessageException>(() => GetMessage(null));
}
[Test]
@@ -174,10 +171,9 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (NoSuchMessageException))]
public void GetMessageNoValidMessage()
{
GetMessage("null", new object[] {"arguments"});
Assert.Throws<NoSuchMessageException>(() => GetMessage("null", new object[] {"arguments"}));
}
[Test]

View File

@@ -21,7 +21,6 @@
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using NUnit.Framework;
@@ -431,11 +430,10 @@ namespace Spring.Context.Support
[Test]
[ExpectedException(typeof (ApplicationContextException))]
public void InvalidContextSubclass()
{
ApplicationObjectSupport support = new MyApplicationObjectSupport();
support.ApplicationContext = new MyContext2();
Assert.Throws<ApplicationContextException>(() => support.ApplicationContext = new MyContext2());
}
[Test]
@@ -472,12 +470,11 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (ApplicationContextException))]
public void ReinitWithDiffContext()
{
MockApplicationContext ctx = new MockApplicationContext();
ApplicationObjectSupport support = new MyApplicationObjectSupport(ctx);
support.ApplicationContext = new MockApplicationContext();
Assert.Throws<ApplicationContextException>(() => support.ApplicationContext = new MockApplicationContext());
}
}
}

View File

@@ -20,13 +20,11 @@
#region Imports
using System;
using System.Configuration;
using System.IO;
using System.Security.Policy;
using System.Xml;
using NUnit.Framework;
using Spring.Objects;
using Spring.Objects.Factory;
using Spring.Util;
@@ -117,7 +115,6 @@ namespace Spring.Context.Support
/// Expect failure when using a type that does not inherit from IApplicationContext
/// </summary>
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void ContextNotOfCorrectType()
{
const string xmlData =
@@ -126,15 +123,14 @@ namespace Spring.Context.Support
</context>";
CreateConfigurationElement(xmlData);
ContextHandler ctxHandler = new ContextHandler();
ctxHandler.Create(null, null, configurationElement);
Assert.Throws<ConfigurationErrorsException>(() => ctxHandler.Create(null, null, configurationElement));
}
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void CreatedFromNullXmlElement()
{
ContextHandler ctxHandler = new ContextHandler();
ctxHandler.Create(null, null, null);
Assert.Throws<ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null));
}
[Test]
@@ -151,7 +147,6 @@ namespace Spring.Context.Support
"Default type is not the XmlApplicationContext type; it must be.");
}
[ExpectedException(typeof(ConfigurationErrorsException))]
[Test(Description="SPRNET-105")]
public void ChokesIfChildContextsUseTheSameName()
{
@@ -162,7 +157,7 @@ namespace Spring.Context.Support
</context>";
CreateConfigurationElement(xmlData);
ContextHandler ctxHandler = new ContextHandler();
ctxHandler.Create(null, null, configurationElement);
Assert.Throws<ConfigurationErrorsException>(() => ctxHandler.Create(null, null, configurationElement));
}
private void CreateConfigurationElement(string xmlData)

View File

@@ -135,38 +135,36 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void GetContextWithNullName()
{
ContextRegistry.GetContext(null);
Assert.Throws<ArgumentException>(() => ContextRegistry.GetContext(null));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void GetContextWithEmptyName()
{
ContextRegistry.GetContext("");
Assert.Throws<ArgumentException>(() => ContextRegistry.GetContext(""));
}
[Test]
// [Ignore("How can we test that one ???")]
[ExpectedException(typeof(ApplicationContextException),
ExpectedMessage = "No context registered. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.")]
public void GetRootContextNotRegisteredThrowsException()
{
using (new HookableContextHandler.Guard(new HookableContextHandler.CreateContextFromSectionHandler(GetNullSection)))
Assert.Throws<ApplicationContextException>(() =>
{
IApplicationContext context = ContextRegistry.GetContext();
}
using (new HookableContextHandler.Guard(GetNullSection))
{
ContextRegistry.GetContext();
}
}, "No context registered. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.");
}
[Test]
[ExpectedException(typeof(ApplicationContextException),
ExpectedMessage = "No context registered under name 'bingo'. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.")]
public void GetContextByNameNotRegisteredThrowsException()
{
IApplicationContext context = ContextRegistry.GetContext("bingo");
Assert.Throws<ApplicationContextException>(
() => ContextRegistry.GetContext("bingo"),
"No context registered under name 'bingo'. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.");
}
[Test]
@@ -221,13 +219,12 @@ namespace Spring.Context.Support
}
[Test(Description = "SPRNET-105")]
[ExpectedException(typeof(ApplicationContextException))]
public void ChokesIfChildContextRegisteredUnderNameOfAnExistingContext()
{
MockApplicationContext original = new MockApplicationContext("original");
ContextRegistry.RegisterContext(original);
MockApplicationContext duplicate = new MockApplicationContext("original");
ContextRegistry.RegisterContext(duplicate);
Assert.Throws<ApplicationContextException>(() => ContextRegistry.RegisterContext(duplicate));
}
@@ -256,7 +253,7 @@ namespace Spring.Context.Support
private string _expectedGreatGrandChildName;
[TestFixtureSetUp]
[OneTimeSetUp]
public void InitializeAllTests()
{
_expectedParentName = AbstractApplicationContext.DefaultRootContextName;

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;

View File

@@ -91,11 +91,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageNoDelegateTarget()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(LookupKey);
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(LookupKey));
}
[Test]
@@ -112,11 +111,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageWithCultureNoDelegateTarget()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(LookupKey, CultureInfo.InvariantCulture);
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(LookupKey, CultureInfo.InvariantCulture));
}
[Test]
@@ -133,11 +131,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageWithParamsNoDelegateTarget()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(LookupKey, "Rick", "Evans");
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(LookupKey, "Rick", "Evans"));
}
[Test]
@@ -155,11 +152,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageWithCultureAndParamsNoDelegateTarget()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(LookupKey, CultureInfo.InvariantCulture, "Rick", "Evans");
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(LookupKey, CultureInfo.InvariantCulture, "Rick", "Evans"));
}
[Test]
@@ -194,23 +190,21 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageWithNoParentMessageSourceAndNullDefaultMessageSourceResolvableWithNoCodesAndCulture()
{
IMessageSourceResolvable resolver = new DefaultMessageSourceResolvable(
new string[] {}, new object[] {}, string.Empty);
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(resolver, CultureInfo.InvariantCulture);
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(resolver, CultureInfo.InvariantCulture));
}
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void GetMessageWithNoParentMessageSourceAndNullDefaultMessageSourceResolvableAndCulture()
{
IMessageSourceResolvable resolver = new DefaultMessageSourceResolvable(
new string[] {"foo"}, new object[] {}, string.Empty);
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetMessage(resolver, CultureInfo.InvariantCulture);
Assert.Throws<NoSuchMessageException>(() => source.GetMessage(resolver, CultureInfo.InvariantCulture));
}
[Test]
@@ -227,11 +221,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ApplicationContextException))]
public void GetResourceObjectWithNoParentMessageSource()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetResourceObject(LookupKey);
Assert.Throws<ApplicationContextException>(() => source.GetResourceObject(LookupKey));
}
[Test]
@@ -248,11 +241,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ApplicationContextException))]
public void GetResourceObjectWithNoParentMessageSourceWithCulture()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.GetResourceObject(LookupKey, CultureInfo.InvariantCulture);
Assert.Throws<ApplicationContextException>(() => source.GetResourceObject(LookupKey, CultureInfo.InvariantCulture));
}
[Test]
@@ -267,11 +259,10 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ApplicationContextException))]
public void ApplyResourcesWithNoParentMessageSource()
{
DelegatingMessageSource source = new DelegatingMessageSource();
source.ApplyResources(12, "rick", CultureInfo.InvariantCulture);
Assert.Throws<ApplicationContextException>(() => source.ApplyResources(12, "rick", CultureInfo.InvariantCulture));
}
}
}

View File

@@ -29,13 +29,13 @@ namespace Spring.Context.Support
[TestFixture]
public class MessageSourceAccessorTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
CultureTestScope.Set();
}
[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown()
{
CultureTestScope.Reset();

View File

@@ -49,7 +49,6 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (ArgumentException))]
public void ParseSectionWithHandlerThatDoesNotImplement_IXmlObjectDefinitionParser()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -58,11 +57,10 @@ namespace Spring.Context.Support
</parsers>";
NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof (TypeLoadException))]
public void ParseSectionWithBadTypeForHandler()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -71,7 +69,7 @@ namespace Spring.Context.Support
</parsers>";
NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<TypeLoadException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
@@ -87,7 +85,6 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void ParseSectionWithEmptyType()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -96,11 +93,10 @@ namespace Spring.Context.Support
</parsers>";
NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void WithParserElementThatIsMissingTheTypeAttribute()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -109,7 +105,7 @@ namespace Spring.Context.Support
</parsers>";
NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ConfigurationErrorsException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
private static XmlNode BuildConfigurationSection(string xml)

View File

@@ -18,7 +18,6 @@
#endregion
using System;
using NUnit.Framework;
namespace Spring.Context.Support

View File

@@ -21,7 +21,6 @@
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
@@ -54,13 +53,13 @@ namespace Spring.Context.Support
private const string ResourceBaseName = ResourceNamespace + "." + ResourceFileName;
private IList<object> resourceManagerList;
[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
CultureTestScope.Set();
}
[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown()
{
CultureTestScope.Reset();
@@ -370,11 +369,10 @@ namespace Spring.Context.Support
/// Get exception when resource doesn't exist.
/// </summary>
[Test]
[ExpectedException(typeof(NoSuchMessageException))]
public void ResourceSetMessageSourceGetNonExistantResource()
{
messageSource.ResourceManagers = resourceManagerList;
messageSource.GetMessage("MyNonExistantMessage", CultureInfo.CurrentCulture, new object[] { "Spring", ".NET" });
Assert.Throws<NoSuchMessageException>(() => messageSource.GetMessage("MyNonExistantMessage", CultureInfo.CurrentCulture, new object[] { "Spring", ".NET" }));
}
/// <summary>

View File

@@ -32,13 +32,13 @@ namespace Spring.Context.Support
[TestFixture]
public sealed class StaticMessageSourceTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void TestFixtureSetUp()
{
CultureTestScope.Set();
}
[TestFixtureTearDown]
[OneTimeTearDown]
public void TestFixtureTearDown()
{
CultureTestScope.Reset();

View File

@@ -26,7 +26,6 @@ using System.Xml;
using NUnit.Framework;
using Spring.Core.TypeResolution;
using Spring.Objects;
using Spring.Util;
#endregion
@@ -81,7 +80,6 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof (TypeLoadException))]
public void WithNonExistentType()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -90,11 +88,10 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<TypeLoadException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithEmptyTypeName()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -103,11 +100,10 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithWhitespacedTypeName()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -118,11 +114,10 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithEmptyAlias()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -131,11 +126,10 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithWhitespacedAlias()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -145,7 +139,7 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
@@ -177,7 +171,6 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void WithAliasElementThatIsMissingTheNameAttribute()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -186,11 +179,10 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ConfigurationErrorsException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
[Test]
[ExpectedException(typeof(ConfigurationErrorsException))]
public void WithAliasElementThatIsMissingTheTypeAttribute()
{
const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
@@ -199,7 +191,7 @@ namespace Spring.Context.Support
</typeAliases>";
TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
handler.Create(null, null, BuildConfigurationSection(xml));
Assert.Throws<ConfigurationErrorsException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
}
private static XmlNode BuildConfigurationSection(string xml)

View File

@@ -82,10 +82,9 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void NoConfigLocation()
{
new XmlApplicationContext();
Assert.Throws<ArgumentException>(() => new XmlApplicationContext());
}
[Test]
@@ -155,14 +154,13 @@ namespace Spring.Context.Support
}
[Test]
[ExpectedException(typeof(NoSuchObjectDefinitionException))]
public void GetObjectOnUnknownIdThrowsNoSuchObjectDefinition()
{
XmlApplicationContext ctx =
new XmlApplicationContext(false, "assembly://Spring.Core.Tests/Spring.Context.Support/objects.xml");
string DOES_NOT_EXIST = "does_not_exist";
Assert.IsFalse(ctx.ContainsObject(DOES_NOT_EXIST));
Assert.IsNull(ctx.GetObject(DOES_NOT_EXIST));
Assert.Throws<NoSuchObjectDefinitionException>(() => ctx.GetObject(DOES_NOT_EXIST));
}
[Test]

View File

@@ -54,10 +54,9 @@ namespace Spring.Core.IO
/// comma delimited instead of '/'.
/// </summary>
[Test]
[ExpectedException(typeof(UriFormatException))]
public void CreateWithMalformedResourceName()
{
new AssemblyResource("assembly://Spring.Core.Tests,Spring.TestResource.txt");
Assert.Throws<UriFormatException>(() => new AssemblyResource("assembly://Spring.Core.Tests,Spring.TestResource.txt"));
}
/// <summary>
@@ -65,20 +64,18 @@ namespace Spring.Core.IO
/// that used 'dot' notation to seperate the namespace and resource name.
/// </summary>
[Test]
[ExpectedException(typeof(UriFormatException))]
public void CreateWithObsoleteResourceName()
{
new AssemblyResource("assembly://Spring.Core.Tests/Spring.TestResource.txt");
Assert.Throws<UriFormatException>(() => new AssemblyResource("assembly://Spring.Core.Tests/Spring.TestResource.txt"));
}
/// <summary>
/// Use the correct format but with an invalid assembly name.
/// </summary>
[Test]
[ExpectedException(typeof(FileNotFoundException))]
public void CreateFromInvalidAssembly()
{
new AssemblyResource("assembly://Xyz.Invalid.Assembly/Spring/TestResource.txt");
Assert.Throws<FileNotFoundException>(() => new AssemblyResource("assembly://Xyz.Invalid.Assembly/Spring/TestResource.txt"));
}
/// <summary>
@@ -225,12 +222,10 @@ namespace Spring.Core.IO
/// past the root namespace, off into la-la land.
/// </summary>
[Test]
[ExpectedException(typeof(UriFormatException))]
public void TooMuchParentNamespacesAbove()
{
IResource res = new AssemblyResource("assembly://Spring.Core.Tests/Spring.Core.IO/TestResource.txt");
IResource res2 = res.CreateRelative("../../../../TestResource.txt");
AssertResourceContent(res2, "Spring.TestResource.txt");
Assert.Throws<UriFormatException>(() => res.CreateRelative("../../../../TestResource.txt"));
}
/// <summary>

View File

@@ -1,9 +1,8 @@
using System;
using System.IO;
using System.Net;
using System.Xml;
using NUnit.Framework;
using Spring.Objects.Factory.Xml;
using Spring.Util;
namespace Spring.Core.IO
@@ -58,17 +57,15 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ThrowsOnNullSectionName()
{
new ConfigSectionResource((string)null);
Assert.Throws<ArgumentNullException>(() => new ConfigSectionResource((string) null));
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void ThrowsOnNullConfigElement()
{
new ConfigSectionResource((XmlElement)null);
Assert.Throws<ArgumentNullException>(() => new ConfigSectionResource((XmlElement) null));
}
[Test]

View File

@@ -177,10 +177,9 @@ namespace Spring.Core.IO
#endregion
[Test]
[ExpectedException(typeof(UriFormatException))]
public void GetResourceForNonMappedProtocol()
{
new ConfigurableResourceLoader().GetResource("beep://foo.xml");
Assert.Throws<UriFormatException>(() => new ConfigurableResourceLoader().GetResource("beep://foo.xml"));
}
}
}

View File

@@ -78,12 +78,11 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(FileNotFoundException))]
public void FileSystemResourceOpenNonExistanceFile()
{
FileSystemResource fileSystemResource = CreateResourceInstance(TemporaryFileName);
Stream inputStream = fileSystemResource.InputStream;
inputStream.Close();
Stream inputStream;
Assert.Throws<FileNotFoundException>(() => inputStream = fileSystemResource.InputStream);
}
[Test]
@@ -150,11 +149,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void CreateRelativeWithNullRelativePath()
{
IResource resource = CreateResourceInstance(".");
resource.CreateRelative(null);
Assert.Throws<ArgumentNullException>(() => resource.CreateRelative(null));
}
[Test]
@@ -240,11 +238,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(UriFormatException))]
public void RelativeResourceTooManyBackLevels()
{
FileSystemResource res = CreateResourceInstance("/samples/artfair/dummy.txt");
res.CreateRelative("../../../index.html");
Assert.Throws<UriFormatException>(() => res.CreateRelative("../../../index.html"));
}
[Test]

View File

@@ -49,11 +49,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof (UriFormatException))]
public void RelativeUncResourceTooManyBackLevels()
{
FileSystemResource res = new FileSystemResource(@"\\server\share\samples\artfair\dummy.txt");
res.CreateRelative(@"..\..\..\index.html");
Assert.Throws<UriFormatException>(() => res.CreateRelative(@"..\..\..\index.html"));
}
[Test(Description="SPRNET-89")]

View File

@@ -69,13 +69,12 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void InstantiationWithNull () {
new InputStreamResource (null, "A null resource.");
public void InstantiationWithNull ()
{
Assert.Throws<ArgumentNullException>(() => new InputStreamResource (null, "A null resource."));
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void ReadStreamMultipleTimes ()
{
FileInfo file = null;
@@ -87,7 +86,8 @@ namespace Spring.Core.IO
// attempting to read this stream twice is an error...
InputStreamResource res = new InputStreamResource (stream, "A temporary resource.");
Stream streamOne = res.InputStream;
Stream streamTwo = res.InputStream; // should bail here
Stream streamTwo;
Assert.Throws<InvalidOperationException>(() => streamTwo = res.InputStream); // should bail here
}
finally
{

View File

@@ -39,7 +39,7 @@ namespace Spring.Core.IO
/// <summary>
/// The setup logic executed before the execution of this test fixture.
/// </summary>
[TestFixtureSetUp]
[OneTimeSetUp]
public void FixtureSetUp()
{
// enable (null appender) logging, just to ensure that the logging code is correct
@@ -66,19 +66,17 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof (NotSupportedException))]
public void ConvertFromNullReference()
{
ResourceConverter vrt = new ResourceConverter();
vrt.ConvertFrom(null);
Assert.Throws<NotSupportedException>(() => vrt.ConvertFrom(null));
}
[Test]
[ExpectedException(typeof (NotSupportedException))]
public void ConvertFromNonSupportedOptionBails()
{
ResourceConverter vrt = new ResourceConverter();
vrt.ConvertFrom(new TestFixtureAttribute());
Assert.Throws<NotSupportedException>(() => vrt.ConvertFrom(new TestFixtureAttribute()));
}
[Test]

View File

@@ -36,38 +36,33 @@ namespace Spring.Core.IO
public sealed class ResourceHandlerRegistryTests
{
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithNullProtocolName()
{
ResourceHandlerRegistry.RegisterResourceHandler(null, GetType());
Assert.Throws<ArgumentNullException>(() => ResourceHandlerRegistry.RegisterResourceHandler(null, GetType()));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithNullIResourceHandlerType()
{
ResourceHandlerRegistry.RegisterResourceHandler("beep", (Type) null);
Assert.Throws<ArgumentNullException>(() => ResourceHandlerRegistry.RegisterResourceHandler("beep", (Type) null));
}
[Test]
[ExpectedException(typeof (ArgumentNullException))]
public void WithWhitespacedProtocolName()
{
ResourceHandlerRegistry.RegisterResourceHandler("\t ", GetType());
Assert.Throws<ArgumentNullException>(() => ResourceHandlerRegistry.RegisterResourceHandler("\t ", GetType()));
}
[Test]
[ExpectedException(typeof (ArgumentException))]
public void WithNonIResourceHandlerType()
{
ResourceHandlerRegistry.RegisterResourceHandler("beep", GetType());
Assert.Throws<ArgumentException>(() => ResourceHandlerRegistry.RegisterResourceHandler("beep", GetType()));
}
[Test]
[ExpectedException(typeof (ArgumentException))]
public void WithIResourceHandlerTypeWithNoValidCtor()
{
ResourceHandlerRegistry.RegisterResourceHandler("beep", typeof(IncompatibleResource));
Assert.Throws<ArgumentException>(() => ResourceHandlerRegistry.RegisterResourceHandler("beep", typeof(IncompatibleResource)));
}
[Test]

View File

@@ -72,11 +72,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void DoesntSupportRelativeResources()
{
StringResource r = new StringResource(string.Empty);
r.CreateRelative("foo");
Assert.Throws<NotSupportedException>(() => r.CreateRelative("foo"));
}
[Test]

View File

@@ -45,11 +45,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void CreateInvalidUrlResource()
{
string uri = null;
new UrlResource(uri);
Assert.Throws<ArgumentNullException>(() => new UrlResource(uri));
}
[Test]
@@ -67,21 +66,19 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(FileNotFoundException))]
public void GetInvalidFileInfo()
{
UrlResource urlResource = new UrlResource("http://www.springframework.net/");
FileInfo file = urlResource.File;
file.GetType();
FileInfo file;
Assert.Throws<FileNotFoundException>(() => file = urlResource.File);
}
[Test]
[ExpectedException(typeof(FileNotFoundException))]
public void GetInvalidFileInfoWithOddPort()
{
UrlResource urlResource = new UrlResource("http://www.springframework.net:76/");
FileInfo file = urlResource.File;
file.GetType();
FileInfo temp;
Assert.Throws<FileNotFoundException>(() => temp = urlResource.File);
}
[Test]
@@ -156,11 +153,10 @@ namespace Spring.Core.IO
}
[Test]
[ExpectedException(typeof(UriFormatException))]
public void RelativeResourceTooManyBackLevels()
{
UrlResource res = new UrlResource("http://www.springframework.net/samples/artfair/download.html");
res.CreateRelative("../../../index.html");
Assert.Throws<UriFormatException>(() => res.CreateRelative("../../../index.html"));
}
}
}

View File

@@ -46,18 +46,16 @@ namespace Spring.Core
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void InstantiationBailsWithGenericArgumentCountSetToLessThanZero ()
{
MethodGenericArgumentsCountCriteria criteria = new MethodGenericArgumentsCountCriteria(-10);
Assert.Throws<ArgumentOutOfRangeException>(() => new MethodGenericArgumentsCountCriteria(-10));
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void BailsWhenExpectedGenericArgumentCountSetToLessThanZero()
{
MethodGenericArgumentsCountCriteria criteria = new MethodGenericArgumentsCountCriteria();
criteria.ExpectedGenericArgumentCount = -12;
Assert.Throws<ArgumentOutOfRangeException>(() => criteria.ExpectedGenericArgumentCount = -12);
}
[Test]

View File

@@ -46,18 +46,16 @@ namespace Spring.Core
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void InstantiationBailsWithParameterCountSetToLessThanZero ()
{
MethodParametersCountCriteria criteria = new MethodParametersCountCriteria (-10);
Assert.Throws<ArgumentOutOfRangeException>(() => new MethodParametersCountCriteria (-10));
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void BailsWhenExpectedParameterCountSetToLessThanZero ()
{
MethodParametersCountCriteria criteria = new MethodParametersCountCriteria ();
criteria.ExpectedParameterCount = -12;
Assert.Throws<ArgumentOutOfRangeException>(() => criteria.ExpectedParameterCount = -12);
}
[Test]

View File

@@ -20,11 +20,9 @@
#region Imports
using System;
using System.Reflection;
using NUnit.Framework;
using Spring.Objects;
#endregion

View File

@@ -21,7 +21,6 @@
#region Imports
using System;
using System.Collections;
using NUnit.Framework;
using Spring.Util;

View File

@@ -20,8 +20,6 @@
#region Imports
using System;
using System.Text.RegularExpressions;
using System.Reflection;
using Spring.Objects;

View File

@@ -20,7 +20,6 @@
#region Imports
using System;
using System.Reflection;
using Spring.Objects;

View File

@@ -37,19 +37,17 @@ namespace Spring.Core.TypeConversion
public sealed class CredentialConverterTests
{
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void ConvertFromNullReference()
{
CredentialConverter cc = new CredentialConverter();
cc.ConvertFrom(null);
Assert.Throws<NotSupportedException>(() => cc.ConvertFrom(null));
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void ConvertFromNonSupportedOptionBails()
{
CredentialConverter cc = new CredentialConverter();
cc.ConvertFrom(12);
Assert.Throws<NotSupportedException>(() => cc.ConvertFrom(12));
}
[Test]
@@ -67,19 +65,17 @@ namespace Spring.Core.TypeConversion
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ConvertFromEmptyString()
{
CredentialConverter cc = new CredentialConverter();
cc.ConvertFrom(string.Empty);
Assert.Throws<ArgumentException>(() => cc.ConvertFrom(string.Empty));
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ConvertFromMalformedString()
{
CredentialConverter cc = new CredentialConverter();
object credential = cc.ConvertFrom(@"Spring:bbaia\sprnet");
Assert.Throws<ArgumentException>(() => cc.ConvertFrom(@"Spring:bbaia\sprnet"));
}
[Test]
@@ -97,11 +93,10 @@ namespace Spring.Core.TypeConversion
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ConvertFromStringWithIncorrectDomain()
{
CredentialConverter cc = new CredentialConverter();
object credential = cc.ConvertFrom(@"\bbaia:sprnet");
Assert.Throws<ArgumentException>(() => cc.ConvertFrom(@"\bbaia:sprnet"));
}
[Test]
@@ -119,11 +114,10 @@ namespace Spring.Core.TypeConversion
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void ConvertFromStringWithIncorrectPassword()
{
CredentialConverter cc = new CredentialConverter();
object credential = cc.ConvertFrom(@"\bbaia:");
Assert.Throws<ArgumentException>(() => cc.ConvertFrom(@"\bbaia:"));
}
[Test]

View File

@@ -27,108 +27,97 @@ using NUnit.Framework;
#endregion
namespace Spring.Core.TypeConversion
namespace Spring.Core.TypeConversion
{
/// <summary>
/// Unit tests for the CustomNumberConverter class.
/// </summary>
[TestFixture]
public class CustomNumberConverterTests
public class CustomNumberConverterTests
{
[Test]
public void Instantiation ()
public void Instantiation()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (int), null, true);
= new CustomNumberConverter(typeof(int), null, true);
// mmm, this should still pass... it aint a number though
verter
= new CustomNumberConverter (typeof (bool), null, true);
= new CustomNumberConverter(typeof(bool), null, true);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void InstantiationWithNonPrimitiveType ()
public void InstantiationWithNonPrimitiveType()
{
CustomNumberConverter verter
= new CustomNumberConverter (
typeof (CustomNumberConverterTests), null, true);
Assert.Throws<ArgumentException>(() => new CustomNumberConverter(typeof(CustomNumberConverterTests), null, true));
}
[Test]
public void CanConvertFromString ()
public void CanConvertFromString()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (int), null, true);
Assert.IsTrue (verter.CanConvertFrom (typeof (string)));
Assert.IsFalse (verter.CanConvertFrom (null));
CustomNumberConverter verter = new CustomNumberConverter(typeof(int), null, true);
Assert.IsTrue(verter.CanConvertFrom(typeof(string)));
Assert.IsFalse(verter.CanConvertFrom(null));
}
[Test]
public void ConvertsEmptyStringToZeroWhenAllowed ()
public void ConvertsEmptyStringToZeroWhenAllowed()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (int), null, true);
int actual = (int) verter.ConvertFrom (
null, CultureInfo.CurrentUICulture, string.Empty);
Assert.AreEqual (0, actual);
CustomNumberConverter verter = new CustomNumberConverter(typeof(int), null, true);
int actual = (int) verter.ConvertFrom(null, CultureInfo.CurrentUICulture, string.Empty);
Assert.AreEqual(0, actual);
}
[Test]
public void ConvertFromSupportedNumericType ()
public void ConvertFromSupportedNumericType()
{
Type [] numTypes = new Type [] {
typeof (int),
typeof (uint),
typeof (short),
typeof (ushort),
typeof (long),
typeof (ulong),
typeof (float),
typeof (double),
Type[] numTypes = new Type[]
{
typeof(int),
typeof(uint),
typeof(short),
typeof(ushort),
typeof(long),
typeof(ulong),
typeof(float),
typeof(double),
};
int expected = 12;
foreach (Type numType in numTypes)
foreach (Type numType in numTypes)
{
try
try
{
CustomNumberConverter verter
= new CustomNumberConverter (numType, null, true);
object actual = verter.ConvertFrom (
null, CultureInfo.CurrentUICulture, expected.ToString ());
Assert.AreEqual (expected, actual);
}
catch (Exception ex)
CustomNumberConverter verter = new CustomNumberConverter(numType, null, true);
object actual = verter.ConvertFrom(null, CultureInfo.CurrentUICulture, expected.ToString());
Assert.AreEqual(expected, actual);
}
catch (Exception ex)
{
Assert.Fail ("Bailed when converting type '" + numType + "' : " + ex);
Assert.Fail("Bailed when converting type '" + numType + "' : " + ex);
}
}
}
[Test]
[ExpectedException (typeof (FormatException))]
public void BailsOnEmptyStringWhenNotAllowed ()
public void BailsOnEmptyStringWhenNotAllowed()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (int), null, false);
verter.ConvertFrom (null, CultureInfo.CurrentUICulture, string.Empty);
= new CustomNumberConverter(typeof(int), null, false);
Assert.Throws<FormatException>(() => verter.ConvertFrom(null, CultureInfo.CurrentUICulture, string.Empty));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromNonSupportedNumericTypeOptionBails ()
public void ConvertFromNonSupportedNumericTypeOptionBails()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (char), null, false);
object foo = verter.ConvertFrom ("12");
= new CustomNumberConverter(typeof(char), null, false);
Assert.Throws<NotSupportedException>(() => verter.ConvertFrom("12"));
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromNonSupportedOptionBails ()
public void ConvertFromNonSupportedOptionBails()
{
CustomNumberConverter verter
= new CustomNumberConverter (typeof (int), null, false);
object foo = verter.ConvertFrom (12);
}
CustomNumberConverter verter = new CustomNumberConverter(typeof(int), null, false);
Assert.Throws<NotSupportedException>(() => verter.ConvertFrom(12));
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More