public void RegisteringAnAliasTwiceDoesNotThrowException() { const string Alias = "foo"; TypeRegistry.RegisterType(Alias, typeof(TestObject)); TypeRegistry.RegisterType(Alias, GetType()); Type type = TypeRegistry.ResolveType(Alias); Assert.AreEqual(GetType(), type, "Overriding Type was not registered."); }
public void TestAliasResolution() { TypeRegistry.RegisterType("Foo", typeof(Foo)); TypeRegistry.RegisterType("Bar", "Spring.Objects.Factory.Bar, Spring.Core.Tests"); Assert.AreEqual(TypeRegistry.ResolveType("Foo"), typeof(Foo)); Assert.AreEqual(TypeRegistry.ResolveType("Bar"), typeof(Bar)); IApplicationContext ctx = new XmlApplicationContext("assembly://Spring.Core.Tests/Spring.Core.TypeResolution/aliasedObjects.xml"); Foo foo = ctx.GetObject("aliasedType") as Foo; Assert.IsNotNull(foo); Assert.IsNotNull(foo.Bar); Assert.AreEqual(foo.Bar, typeof(Bar)); Assert.IsTrue(typeof(IBar).IsAssignableFrom(foo.Bar)); }
public void RegisterTypeWithWhitespacedAliasArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(" ", typeof(TestObject))); }
public void RegisterTypeWithEmptyAliasArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(string.Empty, typeof(TestObject))); }
public void RegisterTypeWithNullAliasArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(null, typeof(TestObject))); }
public void RegisterTypeWithWhitespacedTypeStringArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", " ")); }
public void RegisterTypeWithNullTypeStringArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", (string)null)); }
public void RegisterTypeWithEmptyTypeStringArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", string.Empty)); }
public void RegisterTypeWithNullAliasArg() { TypeRegistry.RegisterType(null, typeof(TestObject)); }
public void RegisterTypeWithEmptyAliasArg() { TypeRegistry.RegisterType(string.Empty, typeof(TestObject)); }
public void RegisterTypeWithWhitespacedTypeStringArg() { TypeRegistry.RegisterType("foo", " "); }
public void RegisterTypeWithEmptyTypeStringArg() { TypeRegistry.RegisterType("foo", string.Empty); }
public void RegisterTypeWithNullTypeStringArg() { TypeRegistry.RegisterType("foo", (String)null); }
public void RegisterTypeWithNullTypeArg() { TypeRegistry.RegisterType("foo", (Type)null); }
public void RegisterTypeWithWhitespacedAliasArg() { TypeRegistry.RegisterType(" ", typeof(TestObject)); }