~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/DialogXmlGeneration/ListBoxItemAddedTestFixture.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
        /// Adds two new items to the list box.
 
17
        /// </summary>
 
18
        [TestFixture]
 
19
        public class ListBoxItemAddedTestFixture : DialogLoadingTestFixtureBase
 
20
        {
 
21
                int listBoxItemCount;
 
22
                string listBoxItem1Text;
 
23
                string listBoxItem2Text;
 
24
                
 
25
                [TestFixtureSetUp]
 
26
                public void SetUpFixture()
 
27
                {
 
28
                        WixDocument doc = new WixDocument();
 
29
                        doc.LoadXml(GetWixXml());
 
30
                        CreatedComponents.Clear();
 
31
                        WixDialog wixDialog = doc.CreateWixDialog("WelcomeDialog", new MockTextFileReader());
 
32
                        using (Form dialog = wixDialog.CreateDialog(this)) {
 
33
 
 
34
                                ListBox listBox = (ListBox)dialog.Controls[0];
 
35
                                listBox.Items.Add("New item1");
 
36
                                listBox.Items.Add("New item2");
 
37
                                
 
38
                                XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog);
 
39
                                XmlElement listBoxElement = (XmlElement)dialogElement.SelectSingleNode("//w:ListBox[@Property='ListBoxProperty']", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable));
 
40
                                
 
41
                                listBoxItemCount = listBoxElement.ChildNodes.Count;
 
42
                                XmlElement listBoxItem1Element = (XmlElement)listBoxElement.ChildNodes[0];
 
43
                                listBoxItem1Text = listBoxItem1Element.GetAttribute("Text");
 
44
                                XmlElement listBoxItem2Element = (XmlElement)listBoxElement.ChildNodes[1];
 
45
                                listBoxItem2Text = listBoxItem2Element.GetAttribute("Text");
 
46
                        }
 
47
                }
 
48
                
 
49
                [Test]
 
50
                public void TwoListBoxItems()
 
51
                {
 
52
                        Assert.AreEqual(2, listBoxItemCount);
 
53
                }
 
54
 
 
55
                [Test]
 
56
                public void ListBoxItem1Text()
 
57
                {
 
58
                        Assert.AreEqual("New item1", listBoxItem1Text);
 
59
                }
 
60
                
 
61
                [Test]
 
62
                public void ListBoxItem2Text()
 
63
                {
 
64
                        Assert.AreEqual("New item2", listBoxItem2Text);
 
65
                }
 
66
 
 
67
                string GetWixXml()
 
68
                {
 
69
                        return "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
 
70
                                "\t<Fragment>\r\n" +
 
71
                                "\t\t<UI>\r\n" +
 
72
                                "\t\t\t<Dialog Id='WelcomeDialog' Height='270' Width='370'>\r\n" +
 
73
                                "\t\t\t\t<Control Id='ListBox1' Type='ListBox' X='20' Y='187' Width='330' Height='40' Property='ListBoxProperty'/>\r\n" +
 
74
                                "\t\t\t</Dialog>\r\n" +
 
75
                                "\t\t\t<ListBox Property='ListBoxProperty'>\r\n" +
 
76
                                "\t\t\t</ListBox>\r\n" +
 
77
                                "\t\t</UI>\r\n" +
 
78
                                "\t</Fragment>\r\n" +
 
79
                                "</Wix>";
 
80
                }
 
81
        }
 
82
}