~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/DialogXmlGeneration/NonRadioButtonAddedToGroupTestFixture.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.DialogXmlGeneration
 
14
{
 
15
        /// <summary>
 
16
        /// A non radio button control is added to a panel containing radio buttons.
 
17
        /// This test fixture checks that the non-radio button control is ignored.
 
18
        /// </summary>
 
19
        [TestFixture]
 
20
        public class NonRadioButtonAddedToGroupTestFixture : DialogLoadingTestFixtureBase
 
21
        {
 
22
                XmlElement acceptRadioButtonElement;
 
23
                int controlElementCount;
 
24
                int radioButtonElementCount;
 
25
                
 
26
                [TestFixtureSetUp]
 
27
                public void SetUpFixture()
 
28
                {
 
29
                        WixDocument doc = new WixDocument();
 
30
                        doc.LoadXml(GetWixXml());
 
31
                        CreatedComponents.Clear();
 
32
                        WixDialog wixDialog = doc.CreateWixDialog("AcceptLicenseDialog", new MockTextFileReader());
 
33
                        using (Form dialog = wixDialog.CreateDialog(this)) {
 
34
 
 
35
                                RadioButtonGroupBox radioButtonGroup = (RadioButtonGroupBox)dialog.Controls[0];
 
36
                                Label label1 = new Label();
 
37
                                label1.Left = 100;
 
38
                                label1.Top = 30;
 
39
                                radioButtonGroup.Controls.Add(label1);
 
40
                                radioButtonGroup.Controls.SetChildIndex(label1, 0);
 
41
                        
 
42
                                Label label2 = new Label();
 
43
                                label2.Left = 100;
 
44
                                label2.Top = 30;
 
45
                                radioButtonGroup.Controls.Add(label2);
 
46
                                
 
47
                                // Add a panel to the dialog controls.
 
48
                                Panel panel = new Panel();
 
49
                                panel.Left = 100;
 
50
                                panel.Top = 30;
 
51
                                dialog.Controls.Add(panel);
 
52
                                                                
 
53
                                XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog);
 
54
                                XmlElement radioButtonGroupElement = (XmlElement)dialogElement.SelectSingleNode("w:Control[@Id='Buttons']", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable));
 
55
                                acceptRadioButtonElement = (XmlElement)radioButtonGroupElement.SelectSingleNode("//w:RadioButtonGroup/w:RadioButton", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable));
 
56
                                
 
57
                                controlElementCount = dialogElement.SelectNodes("w:Control", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable)).Count;
 
58
                                radioButtonElementCount = radioButtonGroupElement.SelectNodes("//w:RadioButtonGroup//w:RadioButton", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable)).Count;                             
 
59
                        }
 
60
                }
 
61
                
 
62
                [Test]
 
63
                public void OneControlElement()
 
64
                {
 
65
                        Assert.AreEqual(1, controlElementCount);
 
66
                }
 
67
                
 
68
                [Test]
 
69
                public void TwoRadioButtonElements()
 
70
                {
 
71
                        Assert.AreEqual(2, radioButtonElementCount);
 
72
                }
 
73
                
 
74
                [Test]
 
75
                public void AcceptRadioButtonX()
 
76
                {
 
77
                        Assert.AreEqual("5", acceptRadioButtonElement.GetAttribute("X"));
 
78
                }
 
79
                
 
80
                [Test]
 
81
                public void AcceptRadioButtonY()
 
82
                {
 
83
                        Assert.AreEqual("0", acceptRadioButtonElement.GetAttribute("Y"));
 
84
                }
 
85
                
 
86
                [Test]
 
87
                public void AcceptRadioButtonHeight()
 
88
                {
 
89
                        Assert.AreEqual("15", acceptRadioButtonElement.GetAttribute("Height"));
 
90
                }
 
91
                
 
92
                [Test]
 
93
                public void AcceptRadioButtonWidth()
 
94
                {
 
95
                        Assert.AreEqual("300", acceptRadioButtonElement.GetAttribute("Width"));
 
96
                }
 
97
 
 
98
                string GetWixXml()
 
99
                {
 
100
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
101
                                "\t<Fragment>\r\n" +
 
102
                                "\t\t<UI>\r\n" +
 
103
                                "\t\t\t<Dialog Id='AcceptLicenseDialog' Height='270' Width='370'>\r\n" +
 
104
                                "\t\t\t\t<Control Id='Buttons' Type='RadioButtonGroup' X='20' Y='187' Width='330' Height='40' Property='AcceptLicense'/>\r\n" +
 
105
                                "\t\t\t</Dialog>\r\n" +
 
106
                                "\t\t\t<RadioButtonGroup Property='AcceptLicense'>\r\n" +
 
107
                                "\t\t\t\t<RadioButton Text='I accept' X='5' Y='0' Width='300' Height='15' Value='Yes'/>\r\n" +
 
108
                                "\t\t\t\t<RadioButton Text='I do not accept' X='5' Y='20' Width='300' Height='15'  Value='No'/>\r\n" +
 
109
                                "\t\t\t</RadioButtonGroup>\r\n" +
 
110
                                "\t\t</UI>\r\n" +
 
111
                                "\t</Fragment>\r\n" +
 
112
                                "</Wix>";
 
113
                }
 
114
        }
 
115
}