#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.Drawing;
using System.Resources;
using System.Windows.Forms;
using NUnit.Framework;
using Ingenious.Mvc.Configuration;
using Ingenious.Mvc.Views;
using Ingenious.Mvc.Windows.Forms.Views;
using Ingenious.Mvc.UnitTest.MockTypes;
namespace Ingenious.Mvc.UnitTest.Windows.Forms.Views{
/// <summary>
/// Unit tests the <see cref="WizardForm"/> class.
/// </summary>
public sealed class WizardFormTest : UnitTestBase
{
private WizardForm _form;
protected override void SetUp()
{
_form = new WizardForm();
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestSetCustomConfigurationNull()
{
((ICustomConfigurable) _form).SetCustomConfiguration(null);
}
[Test]
[ExpectedException(typeof(ViewException), "The WizardForm class requires an instance of 'Ingenious.Mvc.Windows.Forms.Views.WizardForm+CustomConfiguration' for its custom configuration but was given an instance of 'System.String'.")]
public void TestSetCustomConfigurationWrongType()
{
((ICustomConfigurable) _form).SetCustomConfiguration("test");
}
[Test]
public void TestSetCustomConfigurationValid()
{
Ingenious.Mvc.Windows.Forms.Views.WizardForm.CustomConfiguration customConfig = new Ingenious.Mvc.Windows.Forms.Views.WizardForm.CustomConfiguration();
customConfig.Title = "myTitle";
customConfig.PreviousText = "myPreviousText";
customConfig.NextText = "myNextText";
customConfig.FinishText = "myFinishText";
customConfig.CancelText = "myCancelText";
ResourceManager resourceManager = new ResourceManager(typeof(WizardFormXmlCustomParserTest));
customConfig.Image = (Image) resourceManager.GetObject("WizardImage");
((ICustomConfigurable) _form).SetCustomConfiguration(customConfig);
Assert.AreEqual("myTitle", _form.Text);
Assert.AreEqual("myPreviousText", _form.PreviousText);
Assert.AreEqual("myNextText", _form.NextText);
Assert.AreEqual("myFinishText", _form.FinishText);
Assert.AreEqual("myCancelText", _form.CancelText);
Assert.AreSame(customConfig.Image, _form.Image);
}
}
}
|