示例#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.");
        }
示例#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);
        }
示例#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);
            }
        }
示例#4
0
        public void CreatedFromNullXmlElement()
        {
            ContextHandler ctxHandler = new ContextHandler();

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