Ejemplo n.º 1
0
        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.");
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public void RegisterTypeWithWhitespacedAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("   ", typeof(TestObject)));
 }
Ejemplo n.º 4
0
 public void RegisterTypeWithEmptyAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(string.Empty, typeof(TestObject)));
 }
Ejemplo n.º 5
0
 public void RegisterTypeWithNullAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(null, typeof(TestObject)));
 }
Ejemplo n.º 6
0
 public void RegisterTypeWithWhitespacedTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", "   "));
 }
Ejemplo n.º 7
0
 public void RegisterTypeWithEmptyTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", string.Empty));
 }
Ejemplo n.º 8
0
 public void RegisterTypeWithNullTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", (string)null));
 }