public void ContextNotOfCorrectType()
        {
            const string xmlData =
                @"<context type='Spring.Objects.TestObject, Spring.Core.Tests'>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";

            CreateConfigurationElement(xmlData);
            ContextHandler ctxHandler = new ContextHandler();

            ctxHandler.Create(null, null, configurationElement);
        }
Esempio n. 2
0
        public void ChokesIfChildContextsUseTheSameName()
        {
            const string xmlData =
                @"<context>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
	<context/>
</context>";

            CreateConfigurationElement(xmlData);
            ContextHandler ctxHandler = new ContextHandler();

            ctxHandler.Create(null, null, configurationElement);
        }
		public void CreateContextSuccessful()
		{
			const string xmlData =
				@"<context type='Spring.Context.Support.XmlApplicationContext, Spring.Core'>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";
			CreateConfigurationElement(xmlData);

			ContextHandler ctxHandler = new ContextHandler();
			IApplicationContext ctx = (IApplicationContext) ctxHandler.Create(null, null, configurationElement);
			Assert.AreEqual(ctx, ContextRegistry.GetContext());
			Assert.AreEqual(1, ContextRegistry.GetContext().ObjectDefinitionCount);
		}
Esempio n. 4
0
        public void DefaultsToXmlApplicationContextType()
        {
            const string xmlData =
                @"<context>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";

            CreateConfigurationElement(xmlData);
            ContextHandler      ctxHandler = new ContextHandler();
            IApplicationContext ctx        = (IApplicationContext)ctxHandler.Create(null, null, configurationElement);

            Assert.AreEqual(typeof(XmlApplicationContext), ctx.GetType(),
                            "Default type is not the XmlApplicationContext type; it must be.");
        }
Esempio n. 5
0
        public void CreateContextSuccessful()
        {
            const string xmlData =
                @"<context type='Spring.Context.Support.XmlApplicationContext, Spring.Core'>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";

            CreateConfigurationElement(xmlData);

            ContextHandler      ctxHandler = new ContextHandler();
            IApplicationContext ctx        = (IApplicationContext)ctxHandler.Create(null, null, configurationElement);

            Assert.AreEqual(ctx, ContextRegistry.GetContext());
            Assert.AreEqual(1, ContextRegistry.GetContext().ObjectDefinitionCount);
        }
        public void CreateRootContextFailure()
        {
            const string xmlData =
                      @"<context type='Spring.Context.Support.XmlApplicationContext, Spring.Core'>
	<resource uri='assembly://Spring.Core.Tests/DoesNotExist.xml'/>
</context>";
            CreateConfigurationElement(xmlData);

            ContextHandler ctxHandler = new ContextHandler();
            try
            {
                IApplicationContext ctx = (IApplicationContext) ctxHandler.Create(null, null, configurationElement);
                Assert.Fail("");
            }
            catch(ConfigurationException cfgex)
            {
                Assert.IsInstanceOf(typeof(ObjectDefinitionStoreException), cfgex.InnerException);
            }
        }
Esempio n. 7
0
        public void CreateChildContextFailure()
        {
            const string xmlData =
                @"<context type='Spring.Context.Support.XmlApplicationContext, Spring.Core'>
	<resource uri='assembly://Spring.Core.Tests/DoesNotExist.xml'/>
</context>";

            CreateConfigurationElement(xmlData);

            ContextHandler ctxHandler = new ContextHandler();

            try
            {
                IApplicationContext ctx = (IApplicationContext)ctxHandler.Create(new StaticApplicationContext(), null, configurationElement);
                Assert.Fail("");
            }
            catch (ConfigurationException cfgex)
            {
                Assert.IsInstanceOf(typeof(ObjectDefinitionStoreException), cfgex.InnerException);
            }
        }
Esempio n. 8
0
        public void CreatedFromNullXmlElement()
        {
            ContextHandler ctxHandler = new ContextHandler();

            ctxHandler.Create(null, null, null);
        }
		public void ChokesIfChildContextsUseTheSameName()
		{
			const string xmlData =
				@"<context>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
	<context/>
</context>";
			CreateConfigurationElement(xmlData);
			ContextHandler ctxHandler = new ContextHandler();
			ctxHandler.Create(null, null, configurationElement);
        }
		public void DefaultsToXmlApplicationContextType()
		{
			const string xmlData =
				@"<context>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";
			CreateConfigurationElement(xmlData);
			ContextHandler ctxHandler = new ContextHandler();
			IApplicationContext ctx = (IApplicationContext) ctxHandler.Create(null, null, configurationElement);
			Assert.AreEqual(typeof (XmlApplicationContext), ctx.GetType(),
			                "Default type is not the XmlApplicationContext type; it must be.");
		}
		public void CreatedFromNullXmlElement()
		{
			ContextHandler ctxHandler = new ContextHandler();
			ctxHandler.Create(null, null, null);
		}
		public void ContextNotOfCorrectType()
		{
			const string xmlData =
				@"<context type='Spring.Objects.TestObject, Spring.Core.Tests'>
	<resource uri='assembly://Spring.Core.Tests/Spring.Resources/SimpleAppContext.xml'/>
</context>";
			CreateConfigurationElement(xmlData);
			ContextHandler ctxHandler = new ContextHandler();
			ctxHandler.Create(null, null, configurationElement);
		}
        public void CreatedFromNullXmlElement()
        {
            ContextHandler ctxHandler = new ContextHandler();

            Assert.Throws <ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null));
        }
		public void CreatedFromNullXmlElement()
		{
			ContextHandler ctxHandler = new ContextHandler();
            Assert.Throws<ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null));
		}