Fixed .NET 1.x build (related to SPRNET-1125)

This commit is contained in:
bbaia
2008-12-09 23:07:13 +00:00
parent eb723a445a
commit 182e3997ba
2 changed files with 29 additions and 22 deletions

View File

@@ -454,6 +454,7 @@ namespace Spring.Objects.Factory
.RegisterSingleton(null, DBNull.Value);
}
#if NET_2_0
[Test]
public void GetSingletonNamesReflectsOrderOfRegistration()
{
@@ -470,6 +471,7 @@ namespace Spring.Objects.Factory
of.RegisterSingleton("B", new object());
Assert.AreEqual(new string[] { "A", "C", "B"}, of.GetSingletonNames(typeof(object)));
}
#endif
[Test]
[ExpectedException(typeof(ArgumentNullException))]

View File

@@ -75,6 +75,7 @@ namespace Spring.Objects.Factory
Assert.AreEqual(6, names.Count);
}
#if NET_2_0
[Test]
public void ObjectNamesIncludingAncestorsPreserveOrderOfRegistration()
{
@@ -82,18 +83,19 @@ namespace Spring.Objects.Factory
IConfigurableListableObjectFactory of = (IConfigurableListableObjectFactory) mocks.DynamicMock(typeof (IConfigurableListableObjectFactory));
IConfigurableListableObjectFactory ofParent = (IConfigurableListableObjectFactory) mocks.DynamicMock(typeof (IConfigurableListableObjectFactory));
using(mocks.Record())
{
Expect.Call(of.GetObjectDefinitionNames()).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectDefinitionNames()).Return(new string[] { "obj2A", "objB", "obj2C" });
}
Expect.Call(of.GetObjectDefinitionNames()).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectDefinitionNames()).Return(new string[] { "obj2A", "objB", "obj2C" });
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesIncludingAncestors(of);
Assert.AreEqual(5, names.Length);
Assert.AreEqual(new string[] { "objA","objB","objC","obj2A","obj2C" }, names);
mocks.ReplayAll();
mocks.VerifyAll();
}
#endif
[Test]
public void ObjectNamesForTypeIncludingAncestors()
@@ -107,25 +109,26 @@ namespace Spring.Objects.Factory
Assert.IsTrue(names.Contains("testFactory2"));
}
#if NET_2_0
[Test]
public void ObjectNamesForTypeIncludingAncestorsPreserveOrderOfRegistration()
{
MockRepository mocks = new MockRepository();
IConfigurableListableObjectFactory of = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
IConfigurableListableObjectFactory ofParent = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
Type EXPECTEDTYPE = typeof (ITestObject);
Type EXPECTEDTYPE = typeof(ITestObject);
using (mocks.Record())
{
Expect.Call(of.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "obj2A", "objB", "obj2C" });
}
Expect.Call(of.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "obj2A", "objB", "obj2C" });
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE);
Assert.AreEqual(5, names.Length);
Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);
mocks.ReplayAll();
mocks.VerifyAll();
}
[Test]
@@ -136,18 +139,20 @@ namespace Spring.Objects.Factory
IConfigurableListableObjectFactory ofParent = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
Type EXPECTEDTYPE = typeof(ITestObject);
using (mocks.Record())
{
Expect.Call(of.GetObjectNamesForType(EXPECTEDTYPE, false, false)).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE, false, false)).Return(new string[] { "obj2A", "objB", "obj2C" });
}
Expect.Call(of.GetObjectNamesForType(EXPECTEDTYPE, false, false)).Return(new string[] { "objA", "objB", "objC" });
Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE, false, false)).Return(new string[] { "obj2A", "objB", "obj2C" });
mocks.ReplayAll();
string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false);
Assert.AreEqual(5, names.Length);
Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);
mocks.ReplayAll();
mocks.VerifyAll();
}
#endif
[Test]
public void CountObjectsIncludingAncestorsWithNonHierarchicalFactory()