~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/WixBinding/Test/PackageFiles/AllowedChildElementsTestFixture.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.SharpDevelop.Project;
 
5
using ICSharpCode.WixBinding;
 
6
using NUnit.Framework;
 
7
using System;
 
8
using System.Collections.Specialized;
 
9
using System.IO;
 
10
using System.Xml;
 
11
using WixBinding.Tests.Utils;
 
12
 
 
13
namespace WixBinding.Tests.PackageFiles
 
14
{
 
15
        /// <summary>
 
16
        /// Tests the child elements that can be added to the selected node.
 
17
        /// </summary>
 
18
        [TestFixture]
 
19
        public class AllowedChildElementsTestFixture : PackageFilesTestFixtureBase
 
20
        {
 
21
                string[] childElementAllowedWhenNoItemSelected;
 
22
                StringCollection childElementsAllowedWhenDirectoryElementSelected;
 
23
                string[] expectedDirectoryChildElementNames;
 
24
                
 
25
                [TestFixtureSetUp]
 
26
                public void SetUpFixture()
 
27
                {
 
28
                        base.InitFixture();
 
29
                        childElementAllowedWhenNoItemSelected = new string[view.AllowedChildElements.Count];
 
30
                        view.AllowedChildElements.CopyTo(childElementAllowedWhenNoItemSelected, 0);
 
31
                        WixDirectoryElement rootDir = editor.Document.GetRootDirectory();
 
32
                        XmlElement directoryElement = (XmlElement)rootDir.ChildNodes[0];
 
33
                        view.SelectedElement = directoryElement;
 
34
                        editor.SelectedElementChanged();
 
35
                        childElementsAllowedWhenDirectoryElementSelected = view.AllowedChildElements;
 
36
                        
 
37
                        WixSchemaCompletion schema = new WixSchemaCompletion();
 
38
                        expectedDirectoryChildElementNames = schema.GetChildElements(directoryElement.Name);
 
39
                }
 
40
                
 
41
                [Test]
 
42
                public void NoElementSelectedOneChildElementAllowed()
 
43
                {
 
44
                        Assert.AreEqual(1, childElementAllowedWhenNoItemSelected.Length);
 
45
                }
 
46
                
 
47
                [Test]
 
48
                public void NoElementSelectedChildElementIsDirectory()
 
49
                {
 
50
                        Assert.AreEqual("Directory", childElementAllowedWhenNoItemSelected[0]);
 
51
                }
 
52
                
 
53
                [Test]
 
54
                public void DirectoryElementSelectedChildElementsAllowed()
 
55
                {
 
56
                        foreach (string name in expectedDirectoryChildElementNames) {
 
57
                                Assert.IsTrue(childElementsAllowedWhenDirectoryElementSelected.Contains(name), "Element '" + name + "' is missing");
 
58
                        }
 
59
                }
 
60
                
 
61
                [Test]
 
62
                public void AtLeastOneChildElementAllowedWhenDirectoryElementSelected()
 
63
                {
 
64
                        Assert.IsTrue(childElementsAllowedWhenDirectoryElementSelected.Count > 0);
 
65
                }
 
66
                
 
67
                protected override string GetWixXml()
 
68
                {
 
69
                        return "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\r\n" +
 
70
                                "\t<Product Name=\"MySetup\" \r\n" +
 
71
                                "\t         Manufacturer=\"\" \r\n" +
 
72
                                "\t         Id=\"F4A71A3A-C271-4BE8-B72C-F47CC956B3AA\" \r\n" +
 
73
                                "\t         Language=\"1033\" \r\n" +
 
74
                                "\t         Version=\"1.0.0.0\">\r\n" +
 
75
                                "\t\t<Package Id=\"6B8BE64F-3768-49CA-8BC2-86A76424DFE9\"/>\r\n" +
 
76
                                "\t\t<Directory Id=\"TARGETDIR\" SourceName=\"SourceDir\">\r\n" +
 
77
                                "\t\t\t<Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">\r\n" +
 
78
                                "\t\t\t\t<Directory Id=\"INSTALLDIR\" Name=\"MyApp\">\r\n" +
 
79
                                "\t\t\t\t\t<Component Id=\"CoreComponents\">\r\n" +
 
80
                                "\t\t\t\t\t\t<File Id=\"CoreComponents\">\r\n" +
 
81
                                "\t\t\t\t\t\t</File>\r\n" +
 
82
                                "\t\t\t\t\t</Component>\r\n" +
 
83
                                "\t\t\t\t</Directory>\r\n" +
 
84
                                "\t\t\t</Directory>\r\n" +
 
85
                                "\t\t</Directory>\r\n" +
 
86
                                "\t</Product>\r\n" +
 
87
                                "</Wix>";
 
88
                }
 
89
        }
 
90
}