SPRNET-1124

fixing broken build from inadvertent use of still more non-.NET 1.1-compatible elements in code (and a broken test due to changes in .NET 1.1 SP1)
This commit is contained in:
sbohlen
2010-07-29 20:01:35 +00:00
parent 6fbf4b3366
commit ba0966d4b5
4 changed files with 64 additions and 26 deletions

View File

@@ -58,14 +58,24 @@ namespace Spring.Context.Support
{
return;
}
FieldInfo initStateRef = typeof(ConfigurationManager).GetField("s_initState",BindingFlags.NonPublic|BindingFlags.Static);
FieldInfo initStateRef = typeof(ConfigurationManager).GetField("s_initState", BindingFlags.NonPublic | BindingFlags.Static);
object notStarted = Activator.CreateInstance(initStateRef.FieldType);
initStateRef.SetValue(null,notStarted);
initStateRef.SetValue(null, notStarted);
#endif
#if NET_1_1
FieldInfo initStateRef = typeof(ConfigurationSettings).GetField("_initState",BindingFlags.NonPublic|BindingFlags.Static);
object notStarted = Activator.CreateInstance(initStateRef.FieldType);
initStateRef.SetValue(null,notStarted);
if (initStateRef!=null)
{
object notStarted = Activator.CreateInstance(initStateRef.FieldType);
initStateRef.SetValue(null,notStarted);
}
else
{
FieldInfo configurationInitializedRef = typeof(ConfigurationSettings).GetField("_configurationInitialized",BindingFlags.NonPublic|BindingFlags.Static);
configurationInitializedRef.SetValue(null, false);
}
#endif
#if NET_1_0
FieldInfo initStateRef = typeof(ConfigurationSettings).GetField("_configurationInitialized",BindingFlags.NonPublic|BindingFlags.Static);
@@ -90,7 +100,7 @@ namespace Spring.Context.Support
{
return ContextRegistry.GetContext(); // this must fail!
}
#if !NET_1_1
[Test]
public void ThrowsInvalidOperationExceptionOnRecursiveCallsToGetContext()
{
@@ -109,6 +119,7 @@ namespace Spring.Context.Support
}
}
}
#endif
[Test]
public void RegisterRootContext()
@@ -163,7 +174,7 @@ namespace Spring.Context.Support
}
[Test]
// [Ignore("How can we test that one ???")]
// [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()

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections;
using System.Text;
using NUnit.Framework;
namespace Spring.Objects.Factory.Config
@@ -50,13 +49,18 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
}
#if NET_2_0
[Test]
public void Iniitialize_WithStringArray_ThrowsException_WhenOddNumberOfStringsProvided()
{
Assert.Throws<ArgumentOutOfRangeException>(() => new DictionaryVariableSource(new string[] { "key1", "value1", "key2", "value2", "orphanedKey1" }));
try
{
new DictionaryVariableSource(new string[] { "key1", "value1", "key2", "value2", "orphanedKey1" });
Assert.Fail("Expected ArgumentOutOfRangeException not thrown.");
}
catch (ArgumentOutOfRangeException)
{
}
}
#endif
[Test]
public void Initialize_WithCaseSensitiveFlag_AddsCaseSensitiveKeys()
@@ -119,7 +123,7 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
}
#if NET_2_0
#if (!NET_2_0 && !NET_1_0 && !NET_1_1)
[Test]
public void Initialize_WithInlineDictionarySyntax()
{
@@ -131,7 +135,6 @@ namespace Spring.Objects.Factory.Config
}
#endif
#if NET_2_0
[Test]
public void Requesting_KeyNotFound_ThrowsException()
{
@@ -140,8 +143,14 @@ namespace Spring.Objects.Factory.Config
DictionaryVariableSource dvs = new DictionaryVariableSource();
dvs.Add(THE_KEY, "value-found");
Assert.Throws<ArgumentException>(() => dvs.ResolveVariable("not" + THE_KEY));
try
{
dvs.ResolveVariable("not" + THE_KEY);
Assert.Fail("Expected ArgumentException not thrown.");
}
catch (ArgumentException)
{
}
}
#endif
}
}

View File

@@ -34,28 +34,40 @@ namespace Spring.Objects.Factory.Config
public class VariablePlaceholderConfigurerTests
{
#if NET_2_0
[Test]
public void ThrowsOnMissingVariableSources()
{
StaticApplicationContext ac = new StaticApplicationContext();
VariablePlaceholderConfigurer vphc = new VariablePlaceholderConfigurer();
Assert.Throws<ArgumentException>(() => vphc.PostProcessObjectFactory(ac.ObjectFactory));
}
#endif
#if NET_2_0
try
{
vphc.PostProcessObjectFactory(ac.ObjectFactory);
Assert.Fail("Expected ArgumentException not thrown.");
}
catch (ArgumentException)
{
}
}
[Test]
public void ThrowsOnInvalidVariableSourcesElement()
{
StaticApplicationContext ac = new StaticApplicationContext();
VariablePlaceholderConfigurer vphc = new VariablePlaceholderConfigurer();
vphc.VariableSources = new ArrayList(new object[] { new object() });
Assert.Throws<ArgumentException>(() => vphc.PostProcessObjectFactory(ac.ObjectFactory));
try
{
vphc.PostProcessObjectFactory(ac.ObjectFactory);
Assert.Fail("Expected ArgumentException not thrown.");
}
catch (ArgumentException)
{
}
}
#endif
[Test]
public void SunnyDay()

View File

@@ -67,9 +67,15 @@ namespace Spring.Messaging.Listener
{
TransactionalMessageListenerContainer container = new TransactionalMessageListenerContainer();
ArgumentException ex = Assert.Throws<ArgumentException>(() => container.AfterPropertiesSet());
Assert.AreEqual("Property 'MessageQueueObjectName' is required", ex.Message);
try
{
container.AfterPropertiesSet();
Assert.Fail("Expected ArgumentException not thrown.");
}
catch (ArgumentException ex)
{
Assert.AreEqual("Property 'MessageQueueObjectName' is required", ex.Message);
}
}
[Test]