public void WithEmptyTypeName()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='fiona.apple' type=''/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
        public void WithGenericType()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='myDictionary' type='System.Collections.Generic.Dictionary&lt;int,string>'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
        public void WithNonExistentType()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='fiona.apple' type='schwing'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <TypeLoadException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
        public void WithAliasElementThatIsMissingTheTypeAttribute()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='bing'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <ConfigurationErrorsException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
        public void ParseSectionWithNoChildParserNamespaceElements()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<!-- now't in here -->
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
        public void WithEmptyAlias()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='' type='Oragon.Spring.Objects.TestObject, Oragon.Spring.Core.Tests'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
        public void ParseSectionWithGuffChildParserNamespaceElementsIsAllowed()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<!-- some guff elements -->
	<so/>
	<hot/>
	<right/>
	<now/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
        public void ParseSectionSunnyDay()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='fiona.apple' type='Oragon.Spring.Objects.TestObject, Oragon.Spring.Core.Tests'/>
</typeAliases>";

            Assert.IsNull(TypeRegistry.ResolveType("fiona.apple"), "TypeRegistry already contains an alias for the type being tested (it must not).");

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));

            Type type = TypeRegistry.ResolveType("fiona.apple");

            Assert.AreEqual(typeof(TestObject), type, "The type alias was not registered by the TypeAliasesSectionHandler.");
        }