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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public void WithEmptyAlias()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='' type='Spring.Objects.TestObject, Spring.Core.Tests'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

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

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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)));
        }
Exemplo n.º 7
0
        public void WithAliasElementThatIsMissingTheNameAttribute()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias type='Spring.Objects.TestObject, Spring.Core.Tests'/>
</typeAliases>";

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <ConfigurationErrorsException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
Exemplo n.º 8
0
        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();

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

            TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();

            Assert.Throws <ArgumentNullException>(() => 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='Spring.Objects.TestObject, 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.");
		}
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        public void ParseSectionSunnyDay()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='fiona.apple' type='Spring.Objects.TestObject, 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.");
        }
		public void WithWhitespacedTypeName()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<typeAliases>
	<alias name='fiona.apple' type=' 
  
'/>
</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='Spring.Objects.TestObject, Spring.Core.Tests'/>
</typeAliases>";

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

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

			TypeAliasesSectionHandler handler = new TypeAliasesSectionHandler();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
		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 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 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 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 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)));
		}