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", "Oragon.Spring.Objects.Factory.Bar, Oragon.Spring.Core.Tests"); Assert.AreEqual(TypeRegistry.ResolveType("Foo"), typeof(Foo)); Assert.AreEqual(TypeRegistry.ResolveType("Bar"), typeof(Bar)); IApplicationContext ctx = new XmlApplicationContext("assembly://Oragon.Spring.Core.Tests/Oragon.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 RegisterTypeWithEmptyTypeStringArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", string.Empty)); }
public void RegisterTypeWithNullTypeStringArg() { Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", (string)null)); }