From 7555bd26bcac4006686744be6464d479ea2138c4 Mon Sep 17 00:00:00 2001 From: eeichinger Date: Sun, 8 Jun 2008 20:30:25 +0000 Subject: [PATCH] added tests --- .../Collections/SynchronizedHashtableTests.cs | 125 ++++++++++++++++++ .../Expressions/PropertyOrFieldNodeTests.cs | 58 ++++++++ .../Spring.Core.Tests.2003.csproj | 35 +++++ .../Spring.Core.Tests.2005.csproj | 2 + 4 files changed, 220 insertions(+) create mode 100644 test/Spring/Spring.Core.Tests/Collections/SynchronizedHashtableTests.cs create mode 100644 test/Spring/Spring.Core.Tests/Expressions/PropertyOrFieldNodeTests.cs diff --git a/test/Spring/Spring.Core.Tests/Collections/SynchronizedHashtableTests.cs b/test/Spring/Spring.Core.Tests/Collections/SynchronizedHashtableTests.cs new file mode 100644 index 00000000..423e5a3e --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Collections/SynchronizedHashtableTests.cs @@ -0,0 +1,125 @@ +#region License + +/* + * Copyright © 2002-2008 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 + +#region Imports + +using System; +using System.Collections; +using System.Text; +using NUnit.Framework; + +#endregion + +namespace Spring.Collections +{ + /// + /// + /// + /// Erich Eichinger + /// $Id: $ + [TestFixture] + public class SynchronizedHashtableTests + { + /// + /// On my Notebook gives + /// Normal Hashtable: 00:00:01.5937500 + /// Synced Hashtable: 00:00:02.8593750 + /// + [Test, Explicit] + public void TestLockingPerformanceImpact() + { + StopWatch watch = new StopWatch(); + object[] buckets = new object[10]; + + int iterations = 10000000; + + IDictionary testDict = new Hashtable(); + buckets[5] = "value"; + object testResult; + + using(watch.Start("Normal Hashtable: {0}")) + for(int i=0;i + /// On my Notebook gives + /// Method returning exception: 00:00:00.0156250 + /// Method throwing exception: 00:00:02.1562500 + /// + [Test, Explicit] + public void TestPeformanceImpactOfThrowingExceptions() + { + StopWatch watch = new StopWatch(); + + int iterations = 1000000; + + using(watch.Start("Method returning exception: {0}")) + for(int i=0;i + /// Tests the behavior of PropertyOrFieldNode expression node + /// + /// Erich Eichinger + /// $Id: $ + [TestFixture] + public class PropertyOrFieldNodeTests + { + private class BaseClass + { + public string StringProp { get { return "BaseStringProp"; }} + } + + private class DerivedClass : BaseClass + { + public new DateTime StringProp { get { return new DateTime(2008,1,1); }} + } + + + [Test] + public void UseMostSpecificOverride() + { + PropertyOrFieldNode pofNode = new PropertyOrFieldNode(); + pofNode.Text = "StringProp"; + + Assert.AreEqual(new DateTime(2008,1,1), ((IExpression) pofNode).GetValue(new DerivedClass())); + } + } +} \ No newline at end of file diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj index bd7d0bc4..8d232e5c 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2003.csproj @@ -895,6 +895,41 @@ SubType = "Code" BuildAction = "Compile" /> + + + + + + + Code + Code @@ -276,6 +277,7 @@ +