Example #1
0
        public void DefaultsToXmlApplicationContextType()
        {
            const string xmlData =
                @"<context>
	<resource uri='assembly://Oragon.Spring.Core.Tests/Oragon.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.");
        }
Example #2
0
        public void CreateContextSuccessful()
        {
            const string xmlData =
                @"<context type='Oragon.Spring.Context.Support.XmlApplicationContext, Oragon.Spring.Core'>
	<resource uri='assembly://Oragon.Spring.Core.Tests/Oragon.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);
        }
Example #3
0
        public void CreateChildContextFailure()
        {
            const string xmlData =
                @"<context type='Oragon.Spring.Context.Support.XmlApplicationContext, Oragon.Spring.Core'>
	<resource uri='assembly://Oragon.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);
            }
        }
Example #4
0
        public void CreatedFromNullXmlElement()
        {
            ContextHandler ctxHandler = new ContextHandler();

            Assert.Throws <ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null));
        }