~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/LineTestFixture.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 line.
 
17
        /// </summary>
 
18
        [TestFixture]
 
19
        public class LineTestFixture : DialogLoadingTestFixtureBase
 
20
        {
 
21
                string lineName;
 
22
                Point lineLocation;
 
23
                BorderStyle lineBorder;
 
24
                Size lineSize;
 
25
                
 
26
                [TestFixtureSetUp]
 
27
                public void SetUpFixture()
 
28
                {
 
29
                        CreatedComponents.Clear();
 
30
                        WixDocument doc = new WixDocument();
 
31
                        doc.LoadXml(GetWixXml());
 
32
                        WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
 
33
                        using (Form dialog = wixDialog.CreateDialog(this)) {
 
34
                                Label line = (Label)dialog.Controls[0];
 
35
                                lineName = line.Name;
 
36
                                lineLocation = line.Location;
 
37
                                lineBorder = line.BorderStyle;
 
38
                                lineSize = line.Size;
 
39
                        }
 
40
                }
 
41
                
 
42
                [Test]
 
43
                public void LineName()
 
44
                {
 
45
                        Assert.AreEqual("BottomLine", lineName);
 
46
                }
 
47
                
 
48
                [Test]
 
49
                public void TwoControlsCreated()
 
50
                {
 
51
                        Assert.AreEqual(2, CreatedComponents.Count);
 
52
                }
 
53
                
 
54
                [Test]
 
55
                public void LineLocation()
 
56
                {
 
57
                        int expectedX = Convert.ToInt32(10 * WixDialog.InstallerUnit);
 
58
                        int expectedY = Convert.ToInt32(234 * WixDialog.InstallerUnit);
 
59
                        Point expectedPoint = new Point(expectedX, expectedY);
 
60
                        Assert.AreEqual(expectedPoint, lineLocation);
 
61
                }
 
62
                
 
63
                [Test]
 
64
                public void LineSize()
 
65
                {
 
66
                        int expectedWidth = Convert.ToInt32(360 * WixDialog.InstallerUnit);
 
67
                        int expectedHeight = Convert.ToInt32(2 * WixDialog.InstallerUnit);
 
68
                        Size expectedSize = new Size(expectedWidth, expectedHeight);
 
69
                        
 
70
                        Assert.AreEqual(expectedSize, lineSize);
 
71
                }
 
72
                
 
73
                /// <summary>
 
74
                /// Should be fixed 3d since this gives the best looking line.
 
75
                /// </summary>
 
76
                [Test]
 
77
                public void LineBorder()
 
78
                {
 
79
                        Assert.AreEqual(BorderStyle.Fixed3D, lineBorder);
 
80
                }
 
81
                
 
82
                string GetWixXml()
 
83
                {
 
84
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
85
                                "\t<Fragment>\r\n" +
 
86
                                "\t\t<UI>\r\n" +
 
87
                                "\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" +
 
88
                                "\t\t\t\t<Control Id='BottomLine' Type='Line' X='10' Y='234' Width='360' Height='0' />\r\n" +
 
89
                                "\t\t\t</Dialog>\r\n" +
 
90
                                "\t\t</UI>\r\n" +
 
91
                                "\t</Fragment>\r\n" +
 
92
                                "</Wix>";
 
93
                }
 
94
        }
 
95
}