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.SharpDevelop.Project;
5
using ICSharpCode.WixBinding;
8
using System.Collections.Specialized;
11
using WixBinding.Tests.Utils;
13
namespace WixBinding.Tests.PackageFiles
16
/// Tests the child elements that can be added to the selected node.
19
public class AllowedChildElementsTestFixture : PackageFilesTestFixtureBase
21
string[] childElementAllowedWhenNoItemSelected;
22
StringCollection childElementsAllowedWhenDirectoryElementSelected;
23
string[] expectedDirectoryChildElementNames;
26
public void SetUpFixture()
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;
37
WixSchemaCompletion schema = new WixSchemaCompletion();
38
expectedDirectoryChildElementNames = schema.GetChildElements(directoryElement.Name);
42
public void NoElementSelectedOneChildElementAllowed()
44
Assert.AreEqual(1, childElementAllowedWhenNoItemSelected.Length);
48
public void NoElementSelectedChildElementIsDirectory()
50
Assert.AreEqual("Directory", childElementAllowedWhenNoItemSelected[0]);
54
public void DirectoryElementSelectedChildElementsAllowed()
56
foreach (string name in expectedDirectoryChildElementNames) {
57
Assert.IsTrue(childElementsAllowedWhenDirectoryElementSelected.Contains(name), "Element '" + name + "' is missing");
62
public void AtLeastOneChildElementAllowedWhenDirectoryElementSelected()
64
Assert.IsTrue(childElementsAllowedWhenDirectoryElementSelected.Count > 0);
67
protected override string GetWixXml()
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" +