// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.WixBinding;
using NUnit.Framework;
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using WixBinding;
using WixBinding.Tests.Utils;
namespace WixBinding.Tests.DialogLoading
{
///
/// Tests the loading of a simple Wix dialog that contains a selection tree.
///
[TestFixture]
public class SelectionTreeTestFixture : DialogLoadingTestFixtureBase
{
string name;
Point location;
Size size;
[TestFixtureSetUp]
public void SetUpFixture()
{
CreatedComponents.Clear();
WixDocument doc = new WixDocument();
doc.LoadXml(GetWixXml());
WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
using (Form dialog = wixDialog.CreateDialog(this)) {
TreeView treeView = (TreeView)dialog.Controls[0];
name = treeView.Name;
location = treeView.Location;
size = treeView.Size;
}
}
[Test]
public void Name()
{
Assert.AreEqual("ControlId", name);
}
[Test]
public void TwoControlsCreated()
{
Assert.AreEqual(2, CreatedComponents.Count);
}
[Test]
public void Location()
{
int expectedX = Convert.ToInt32(10 * WixDialog.InstallerUnit);
int expectedY = Convert.ToInt32(10 * WixDialog.InstallerUnit);
Point expectedPoint = new Point(expectedX, expectedY);
Assert.AreEqual(expectedPoint, location);
}
[Test]
public void Size()
{
int expectedWidth = Convert.ToInt32(50 * WixDialog.InstallerUnit);
int expectedHeight = Convert.ToInt32(50 * WixDialog.InstallerUnit);
Size expectedSize = new Size(expectedWidth, expectedHeight);
Assert.AreEqual(expectedSize, size);
}
string GetWixXml()
{
return "\r\n" +
"\t\r\n" +
"\t\t\r\n" +
"\t\t\t\r\n" +
"\t\t\r\n" +
"\t\r\n" +
"";
}
}
}