~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/SelectionTreeTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using ICSharpCode.WixBinding;
 
5
using NUnit.Framework;
 
6
using System;
 
7
using System.Drawing;
 
8
using System.Windows.Forms;
 
9
using System.Xml;
 
10
using WixBinding;
 
11
using WixBinding.Tests.Utils;
 
12
 
 
13
namespace WixBinding.Tests.DialogLoading
 
14
{
 
15
        /// <summary>
 
16
        /// Tests the loading of a simple Wix dialog that contains a selection tree.
 
17
        /// </summary>
 
18
        [TestFixture]
 
19
        public class SelectionTreeTestFixture : DialogLoadingTestFixtureBase
 
20
        {
 
21
                string name;
 
22
                Point location;
 
23
                Size size;
 
24
                
 
25
                [TestFixtureSetUp]
 
26
                public void SetUpFixture()
 
27
                {
 
28
                        CreatedComponents.Clear();
 
29
                        WixDocument doc = new WixDocument();
 
30
                        doc.LoadXml(GetWixXml());
 
31
                        WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
 
32
                        using (Form dialog = wixDialog.CreateDialog(this)) {
 
33
                                TreeView treeView = (TreeView)dialog.Controls[0];
 
34
                                name = treeView.Name;
 
35
                                location = treeView.Location;
 
36
                                size = treeView.Size;
 
37
                        }
 
38
                }
 
39
                
 
40
                [Test]
 
41
                public void Name()
 
42
                {
 
43
                        Assert.AreEqual("ControlId", name);
 
44
                }
 
45
                
 
46
                [Test]
 
47
                public void TwoControlsCreated()
 
48
                {
 
49
                        Assert.AreEqual(2, CreatedComponents.Count);
 
50
                }
 
51
                
 
52
                [Test]
 
53
                public void Location()
 
54
                {
 
55
                        int expectedX = Convert.ToInt32(10 * WixDialog.InstallerUnit);
 
56
                        int expectedY = Convert.ToInt32(10 * WixDialog.InstallerUnit);
 
57
                        Point expectedPoint = new Point(expectedX, expectedY);
 
58
                        Assert.AreEqual(expectedPoint, location);
 
59
                }
 
60
                
 
61
                [Test]
 
62
                public void Size()
 
63
                {
 
64
                        int expectedWidth = Convert.ToInt32(50 * WixDialog.InstallerUnit);
 
65
                        int expectedHeight = Convert.ToInt32(50 * WixDialog.InstallerUnit);
 
66
                        Size expectedSize = new Size(expectedWidth, expectedHeight);
 
67
                        
 
68
                        Assert.AreEqual(expectedSize, size);
 
69
                }
 
70
                
 
71
                string GetWixXml()
 
72
                {
 
73
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
74
                                "\t<Fragment>\r\n" +
 
75
                                "\t\t<UI>\r\n" +
 
76
                                "\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" +
 
77
                                "\t\t\t\t<Control Id='ControlId' Type='SelectionTree' X='10' Y='10' Width='50' Height='50' Text='Text'/>\r\n" +
 
78
                                "\t\t\t</Dialog>\r\n" +
 
79
                                "\t\t</UI>\r\n" +
 
80
                                "\t</Fragment>\r\n" +
 
81
                                "</Wix>";
 
82
                }
 
83
        }
 
84
}