コード例 #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.");
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 public void RegisterTypeWithWhitespacedAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("   ", typeof(TestObject)));
 }
コード例 #4
0
 public void RegisterTypeWithEmptyAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(string.Empty, typeof(TestObject)));
 }
コード例 #5
0
 public void RegisterTypeWithNullAliasArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType(null, typeof(TestObject)));
 }
コード例 #6
0
 public void RegisterTypeWithWhitespacedTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", "   "));
 }
コード例 #7
0
 public void RegisterTypeWithNullTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", (string)null));
 }
コード例 #8
0
 public void RegisterTypeWithEmptyTypeStringArg()
 {
     Assert.Throws <ArgumentNullException>(() => TypeRegistry.RegisterType("foo", string.Empty));
 }
コード例 #9
0
 public void RegisterTypeWithNullAliasArg()
 {
     TypeRegistry.RegisterType(null, typeof(TestObject));
 }
コード例 #10
0
 public void RegisterTypeWithEmptyAliasArg()
 {
     TypeRegistry.RegisterType(string.Empty, typeof(TestObject));
 }
コード例 #11
0
 public void RegisterTypeWithWhitespacedTypeStringArg()
 {
     TypeRegistry.RegisterType("foo", "   ");
 }
コード例 #12
0
 public void RegisterTypeWithEmptyTypeStringArg()
 {
     TypeRegistry.RegisterType("foo", string.Empty);
 }
コード例 #13
0
 public void RegisterTypeWithNullTypeStringArg()
 {
     TypeRegistry.RegisterType("foo", (String)null);
 }
コード例 #14
0
 public void RegisterTypeWithNullTypeArg()
 {
     TypeRegistry.RegisterType("foo", (Type)null);
 }
コード例 #15
0
 public void RegisterTypeWithWhitespacedAliasArg()
 {
     TypeRegistry.RegisterType("   ", typeof(TestObject));
 }