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)
4
using ICSharpCode.WixBinding;
8
using System.Windows.Forms;
11
using WixBinding.Tests.Utils;
13
namespace WixBinding.Tests.DialogXmlGeneration
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.
20
public class NonRadioButtonAddedToGroupTestFixture : DialogLoadingTestFixtureBase
22
XmlElement acceptRadioButtonElement;
23
int controlElementCount;
24
int radioButtonElementCount;
27
public void SetUpFixture()
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)) {
35
RadioButtonGroupBox radioButtonGroup = (RadioButtonGroupBox)dialog.Controls[0];
36
Label label1 = new Label();
39
radioButtonGroup.Controls.Add(label1);
40
radioButtonGroup.Controls.SetChildIndex(label1, 0);
42
Label label2 = new Label();
45
radioButtonGroup.Controls.Add(label2);
47
// Add a panel to the dialog controls.
48
Panel panel = new Panel();
51
dialog.Controls.Add(panel);
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));
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;
63
public void OneControlElement()
65
Assert.AreEqual(1, controlElementCount);
69
public void TwoRadioButtonElements()
71
Assert.AreEqual(2, radioButtonElementCount);
75
public void AcceptRadioButtonX()
77
Assert.AreEqual("5", acceptRadioButtonElement.GetAttribute("X"));
81
public void AcceptRadioButtonY()
83
Assert.AreEqual("0", acceptRadioButtonElement.GetAttribute("Y"));
87
public void AcceptRadioButtonHeight()
89
Assert.AreEqual("15", acceptRadioButtonElement.GetAttribute("Height"));
93
public void AcceptRadioButtonWidth()
95
Assert.AreEqual("300", acceptRadioButtonElement.GetAttribute("Width"));
100
return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\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" +
111
"\t</Fragment>\r\n" +