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);
		}
Exemple #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);
        }
Exemple #3
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.");
        }
Exemple #4
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);
            }
        }
Exemple #6
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);
            }
        }
Exemple #7
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));
		}