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 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); }
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 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); } }
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); } }
public void CreatedFromNullXmlElement() { ContextHandler ctxHandler = new ContextHandler(); ctxHandler.Create(null, null, null); }
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(); Assert.Throws <ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null)); }
public void CreatedFromNullXmlElement() { ContextHandler ctxHandler = new ContextHandler(); Assert.Throws<ConfigurationErrorsException>(() => ctxHandler.Create(null, null, null)); }