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)
5
using ICSharpCode.SharpDevelop.Dom;
6
using ICSharpCode.WixBinding;
8
using WixBinding.Tests.Utils;
10
namespace WixBinding.Tests.Gui
13
public class WixDocumentEditorReplaceElementTestFixture
15
MockTextEditor textEditor;
16
DomRegion replacementRegion;
17
WixDocumentEditor wixDocumentEditor;
22
textEditor = new MockTextEditor();
23
textEditor.Document.Text = GetWixXml();
25
string replacementXml =
29
wixDocumentEditor = new WixDocumentEditor(textEditor);
30
replacementRegion = wixDocumentEditor.ReplaceElement("TARGETDIR", "Directory", replacementXml);
36
"<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
37
"\t<Product Name='Test' \r\n" +
38
"\t Version='1.0' \r\n" +
39
"\t Language='1013' \r\n" +
40
"\t Manufacturer='#develop' \r\n" +
41
"\t Id='????????-????-????-????-????????????'>\r\n" +
42
"\t\t<Package/>\r\n" +
43
"\t\t\t<Directory Id=\"TARGETDIR\" SourceName=\"SourceDir\">\r\n" +
44
"\t\t\t</Directory>\r\n" +
50
public void XmlIsUpdatedInTextEditor()
53
"<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\r\n" +
54
"\t<Product Name='Test' \r\n" +
55
"\t Version='1.0' \r\n" +
56
"\t Language='1013' \r\n" +
57
"\t Manufacturer='#develop' \r\n" +
58
"\t Id='????????-????-????-????-????????????'>\r\n" +
59
"\t\t<Package/>\r\n" +
60
"\t\t\t<NewElement>\r\n" +
61
"\t\t\t</NewElement>\r\n" +
65
Assert.AreEqual(expectedXml, textEditor.Document.Text);
69
public void ReplacementRegionIsNotEmpty()
71
Assert.IsFalse(replacementRegion.IsEmpty);
75
public void ReplacingUnknownElementReturnsEmptyRegion()
77
DomRegion region = wixDocumentEditor.ReplaceElement("TARGETDIR", "unknown-element", "<test/>");
78
Assert.IsTrue(region.IsEmpty);