~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/DialogLoading/SimpleDialogTestFixture.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 has just an id, height and
 
17
        /// width.
 
18
        /// </summary>
 
19
        [TestFixture]
 
20
        public class SimpleDialogTestFixture
 
21
        {
 
22
                string dialogName;
 
23
                FormBorderStyle borderStyle;
 
24
                Size clientSize;
 
25
                bool maximizeBox;
 
26
                bool minimizeBox;
 
27
                WixDocument doc;
 
28
 
 
29
                [TestFixtureSetUp]
 
30
                public void SetUpFixture()
 
31
                {
 
32
                        doc = new WixDocument();
 
33
                        doc.LoadXml(GetWixXml());
 
34
                        WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
 
35
                        using (Form simpleDialog = wixDialog.CreateDialog()) {
 
36
                                dialogName = simpleDialog.Name;
 
37
                                borderStyle = simpleDialog.FormBorderStyle;
 
38
                                clientSize = simpleDialog.ClientSize;
 
39
                                minimizeBox = simpleDialog.MinimizeBox;
 
40
                                maximizeBox = simpleDialog.MaximizeBox;
 
41
                        }
 
42
                }
 
43
                
 
44
                [Test]
 
45
                public void Name()
 
46
                {
 
47
                        Assert.AreEqual("WelcomeDialog", dialogName);
 
48
                }
 
49
                
 
50
                [Test]
 
51
                public void FixedDialogBorder()
 
52
                {
 
53
                        Assert.AreEqual(FormBorderStyle.FixedDialog, borderStyle);
 
54
                }
 
55
                
 
56
                [Test]
 
57
                public void ClientSizeHeight()
 
58
                {
 
59
                        int expectedHeight = Convert.ToInt32(270 * WixDialog.InstallerUnit);
 
60
                        Assert.AreEqual(expectedHeight, clientSize.Height);
 
61
                }
 
62
                
 
63
                [Test]
 
64
                public void ClientSizeWidth()
 
65
                {
 
66
                        int expectedWidth = Convert.ToInt32(370 * WixDialog.InstallerUnit);
 
67
                        Assert.AreEqual(expectedWidth, clientSize.Width);
 
68
                }
 
69
                
 
70
                [Test]
 
71
                public void MinimizeBox()
 
72
                {
 
73
                        Assert.IsTrue(minimizeBox);
 
74
                }
 
75
                
 
76
                [Test]
 
77
                public void MaximizeBox()
 
78
                {
 
79
                        Assert.IsFalse(maximizeBox);
 
80
                }
 
81
                
 
82
                [Test]
 
83
                public void DialogIdWithSingleQuote()
 
84
                {
 
85
                        Assert.IsNull(doc.CreateWixDialog("Test'Id", new MockTextFileReader()));
 
86
                }
 
87
                                
 
88
                string GetWixXml()
 
89
                {
 
90
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
91
                                "\t<Fragment>\r\n" +
 
92
                                "\t\t<UI>\r\n" +
 
93
                                "\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'/>\r\n" +
 
94
                                "\t\t</UI>\r\n" +
 
95
                                "\t</Fragment>\r\n" +
 
96
                                "</Wix>";
 
97
                }
 
98
        }
 
99
}