#region License
/**
* Ingenious MVC : An MVC framework for .NET 2.0
* Copyright (C) 2006, JDP Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: - Kent Boogaart (kentcb@internode.on.net)
*/
#endregion
using System;
using System.IO;
using System.Reflection;
using System.Xml;
using NUnit.Framework;
using Ingenious.Mvc.Configuration;
using Ingenious.Mvc.Configuration.Configurators;
using Ingenious.Mvc.Factories;
using Ingenious.Mvc.UnitTest.MockTypes;
namespace Ingenious.Mvc.UnitTest.Configuration.Configurators{
/// <summary>
/// Unit tests the <see cref="XmlParser"/> type.
/// </summary>
public sealed class XmlResourceConfiguratorTest : UnitTestBase
{
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestConfigureAssemblyNull()
{
XmlResourceConfigurator.Configure(TaskManager, null, "name");
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestConfigureTypeNull()
{
XmlResourceConfigurator.Configure(TaskManager, Assembly.GetCallingAssembly(), null, "name");
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestConfigureNameNull()
{
XmlResourceConfigurator.Configure(TaskManager, Assembly.GetCallingAssembly(), GetType(), null);
}
[Test]
public void TestValidAssemblyAndNameLoad()
{
XmlResourceConfigurator.Configure(TaskManager, Assembly.GetAssembly(typeof(XmlResourceConfiguratorTest)), "Ingenious.Mvc.UnitTest.Configuration.Configurators.XmlResourceConfiguratorTest.xml");
CheckResults();
}
[Test]
public void TestValidAssemblyTypeAndNameLoad()
{
XmlResourceConfigurator.Configure(TaskManager, Assembly.GetAssembly(typeof(XmlResourceConfiguratorTest)), GetType(), "XmlResourceConfiguratorTest.xml");
CheckResults();
}
private void CheckResults()
{
ConfigurationInfo config = TaskManager.ConfigurationInfo;
//check the factories
Assert.AreEqual(typeof(MockControllerFactory), config.ControllerFactory.GetType());
Assert.AreEqual(typeof(MockNavigatorFactory), config.NavigatorFactory.GetType());
Assert.AreEqual(typeof(DefaultViewFactory), config.ViewFactory.GetType());
Assert.AreEqual(typeof(MockViewManagerFactory), config.ViewManagerFactory.GetType());
//check navigator and view counts
Assert.AreEqual(2, config.NavigatorInfos.Count);
Assert.AreEqual(5, config.ViewInfos.Count);
//check view-controller relationships
Assert.AreEqual("Logon", config.ViewInfos["Logon"].ControllerInfo.Id.ToString());
Assert.AreEqual("Logon", config.ViewInfos["LogonProgress"].ControllerInfo.Id.ToString());
Assert.AreEqual("Main", config.ViewInfos["Main"].ControllerInfo.Id.ToString());
Assert.AreEqual("AddClient", config.ViewInfos["AddClient"].ControllerInfo.Id.ToString());
Assert.AreEqual("AddClient", config.ViewInfos["AddClientProgress"].ControllerInfo.Id.ToString());
//check navigator-starting view relationships
Assert.AreEqual("Logon", config.NavigatorInfos["Logon"].StartViewInfo.Id.ToString());
Assert.AreEqual("Main", config.NavigatorInfos["Main"].StartViewInfo.Id.ToString());
//check navigator-view manager relationships
Assert.AreEqual("VM", config.NavigatorInfos["Logon"].ViewManagerInfo.Id.ToString());
Assert.AreEqual("VM", config.NavigatorInfos["Main"].ViewManagerInfo.Id.ToString());
}
}
}
|