Browse Source

Now using one based line and column numbers in Wix addin to match the text editor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5283 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 16 years ago
parent
commit
d6475f8009
  1. 16
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs
  2. 1
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs
  3. 25
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs
  4. 3
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs
  5. 17
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDocumentEditor.cs
  6. 10
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixDocumentLineSegment.cs
  7. 38
      src/AddIns/BackendBindings/WixBinding/Project/Src/WixDocumentReader.cs
  8. 16
      src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin
  9. 25
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetDialogElementRegionTests.cs
  10. 16
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetDialogIdAtLineTestFixture.cs
  11. 12
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetDirectoryElementRegionTests.cs
  12. 12
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetEmptyElementDialogIdAtLineTestFixture.cs
  13. 6
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetProductEndElementLocationTests.cs
  14. 13
      src/AddIns/BackendBindings/WixBinding/Test/Document/GetTwoDialogIdsFromWixDocumentTestFixture.cs
  15. 10
      src/AddIns/BackendBindings/WixBinding/Test/Document/RegionToOffsetTests.cs
  16. 4
      src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertTextTestFixture.cs
  17. 4
      src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertUsesTextEditorPropertiesTestFixture.cs
  18. 8
      src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceTextTestFixture.cs

16
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs

@ -218,14 +218,8 @@ namespace ICSharpCode.WixBinding @@ -218,14 +218,8 @@ namespace ICSharpCode.WixBinding
return;
}
// Find the product end element location.
XmlElement productElement = document.GetProduct();
StringReader reader = new StringReader(textEditor.Document.Text);
string productId = productElement.GetAttribute("Id");
WixDocumentReader wixReader = new WixDocumentReader(reader);
Location location = wixReader.GetEndElementLocation("Product", productId);
Location location = FindProductElementEndLocation(textEditor, document);
if (!location.IsEmpty) {
// Insert the xml with an extra new line at the end.
documentEditor.InsertIndented(location, String.Concat(xml, "\r\n"));
}
}
@ -238,5 +232,13 @@ namespace ICSharpCode.WixBinding @@ -238,5 +232,13 @@ namespace ICSharpCode.WixBinding
WixDocumentEditor documentEditor = new WixDocumentEditor(textEditor);
documentEditor.ReplaceElement(rootDirectoryRef.Id, WixDirectoryRefElement.DirectoryRefElementName, xml);
}
Location FindProductElementEndLocation(ITextEditor textEditor, WixDocument document)
{
XmlElement productElement = document.GetProduct();
string productId = productElement.GetAttribute("Id");
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
return wixReader.GetEndElementLocation("Product", productId);
}
}
}

1
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogListPad.cs

@ -189,7 +189,6 @@ namespace ICSharpCode.WixBinding @@ -189,7 +189,6 @@ namespace ICSharpCode.WixBinding
{
try {
setupDialogListView.BeginUpdate();
// TODO: Intelligent updating.
ShowDialogList();
} finally {
setupDialogListView.EndUpdate();

25
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesigner.cs

@ -68,9 +68,9 @@ namespace ICSharpCode.WixBinding @@ -68,9 +68,9 @@ namespace ICSharpCode.WixBinding
JumpToDialogElement(id);
if (base.Host != null) {
// Reload so the correct dialog is displayed.
this.MergeAndUnloadDesigner();
MergeAndUnloadDesigner();
DialogId = id;
this.ReloadDesignerFromMemory();
ReloadDesignerFromMemory();
} else {
// Need to open the designer.
DialogId = id;
@ -148,7 +148,7 @@ namespace ICSharpCode.WixBinding @@ -148,7 +148,7 @@ namespace ICSharpCode.WixBinding
/// Gets the Wix document filename.
/// </summary>
public string DocumentFileName {
get { return this.PrimaryFileName; }
get { return PrimaryFileName; }
}
/// <summary>
@ -163,19 +163,15 @@ namespace ICSharpCode.WixBinding @@ -163,19 +163,15 @@ namespace ICSharpCode.WixBinding
/// </summary>
public string GetDocumentXml()
{
return this.DesignerCodeFileContent;
return DesignerCodeFileContent;
}
/// <summary>
/// Gets or sets the dialog id currently being designed.
/// </summary>
public string DialogId {
get {
return dialogId;
}
set {
dialogId = value;
}
get { return dialogId; }
set { dialogId = value; }
}
/// <summary>
@ -200,8 +196,7 @@ namespace ICSharpCode.WixBinding @@ -200,8 +196,7 @@ namespace ICSharpCode.WixBinding
{
ITextEditor textEditor = ActiveTextEditor;
if (textEditor != null) {
StringReader reader = new StringReader(textEditor.Document.Text);
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
return wixReader.GetDialogId(textEditor.Caret.Line);
}
return null;
@ -214,8 +209,7 @@ namespace ICSharpCode.WixBinding @@ -214,8 +209,7 @@ namespace ICSharpCode.WixBinding
{
ITextEditor textEditor = ActiveTextEditor;
if (textEditor != null) {
StringReader reader = new StringReader(textEditor.Document.Text);
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
ReadOnlyCollection<string> ids = wixReader.GetDialogIds();
if (ids.Count > 0) {
return ids[0];
@ -274,8 +268,7 @@ namespace ICSharpCode.WixBinding @@ -274,8 +268,7 @@ namespace ICSharpCode.WixBinding
if (dialogId != null) {
ITextEditor textEditor = ActiveTextEditor;
if (textEditor != null) {
StringReader reader = new StringReader(textEditor.Document.Text);
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(textEditor.Document.Text);
Location location = wixReader.GetStartElementLocation("Dialog", dialogId);
textEditor.JumpTo(location.Y, 1);
}

3
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs

@ -91,8 +91,7 @@ namespace ICSharpCode.WixBinding @@ -91,8 +91,7 @@ namespace ICSharpCode.WixBinding
DomRegion GetTextEditorRegionForDialogElement(string dialogId)
{
IDocument document = view.DesignerCodeFileDocument;
StringReader reader = new StringReader(document.Text);
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(document.Text);
return wixReader.GetElementRegion("Dialog", dialogId);
}

17
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDocumentEditor.cs

@ -29,7 +29,6 @@ namespace ICSharpCode.WixBinding @@ -29,7 +29,6 @@ namespace ICSharpCode.WixBinding
this.document = textEditor.Document;
}
/// <summary>
/// Tries to replace the element defined by element name and its Id attribute in the
/// text editor with the specified xml.
@ -39,7 +38,7 @@ namespace ICSharpCode.WixBinding @@ -39,7 +38,7 @@ namespace ICSharpCode.WixBinding
/// <param name="xml">The replacement xml.</param>
public DomRegion ReplaceElement(string elementAttributeId, string elementName, string replacementXml)
{
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(document.Text));
WixDocumentReader wixReader = new WixDocumentReader(document.Text);
DomRegion region = wixReader.GetElementRegion(elementName, elementAttributeId);
if (!region.IsEmpty) {
Replace(region, replacementXml);
@ -67,7 +66,7 @@ namespace ICSharpCode.WixBinding @@ -67,7 +66,7 @@ namespace ICSharpCode.WixBinding
int insertedCharacterCount = IndentAllLinesTheSame(region.BeginLine + 1, region.EndLine + addedLineCount, initialIndent);
// Make sure the text inserted is visible.
textEditor.JumpTo(region.BeginLine + 1, 1);
textEditor.JumpTo(region.BeginLine, 1);
// Select the text just inserted.
int textInsertedLength = insertedCharacterCount + xml.Length;
@ -84,16 +83,16 @@ namespace ICSharpCode.WixBinding @@ -84,16 +83,16 @@ namespace ICSharpCode.WixBinding
/// Inserts and indents the xml at the specified location.
/// </summary>
/// <remarks>
/// Lines and columns are zero based.
/// Lines and columns are one based.
/// </remarks>
public void InsertIndented(int line, int column, string xml)
{
using (textEditor.Document.OpenUndoGroup()) {
// Insert the xml and indent it.
IDocumentLine documentLine = document.GetLine(line + 1);
IDocumentLine documentLine = document.GetLine(line);
int initialIndent = GetIndent(line);
int offset = documentLine.Offset + column;
int offset = documentLine.Offset + column - 1;
int originalLineCount = document.TotalNumberOfLines;
document.Insert(offset, xml);
int addedLineCount = document.TotalNumberOfLines - originalLineCount;
@ -102,7 +101,7 @@ namespace ICSharpCode.WixBinding @@ -102,7 +101,7 @@ namespace ICSharpCode.WixBinding
int insertedCharacterCount = IndentLines(line, line + addedLineCount, initialIndent);
// Make sure the text inserted is visible.
textEditor.JumpTo(line + 1, 1);
textEditor.JumpTo(line, 1);
// Select the text just inserted.
int textInsertedLength = xml.Length + insertedCharacterCount;
@ -158,13 +157,13 @@ namespace ICSharpCode.WixBinding @@ -158,13 +157,13 @@ namespace ICSharpCode.WixBinding
string GetLineAsString(int line)
{
IDocumentLine documentLine = document.GetLine(line + 1);
IDocumentLine documentLine = document.GetLine(line);
return documentLine.Text;
}
int IndentLine(int line, int howManyIndents)
{
IDocumentLine documentLine = document.GetLine(line + 1);
IDocumentLine documentLine = document.GetLine(line);
int offset = documentLine.Offset;
string indentationString = GetIndentationString(howManyIndents);

10
src/AddIns/BackendBindings/WixBinding/Project/Src/WixDocumentLineSegment.cs

@ -67,9 +67,9 @@ namespace ICSharpCode.WixBinding @@ -67,9 +67,9 @@ namespace ICSharpCode.WixBinding
static WixDocumentLineSegment ConvertRegionToSingleLineSegment(IDocument document, DomRegion region)
{
IDocumentLine documentLine = document.GetLine(region.BeginLine + 1);
return new WixDocumentLineSegment(documentLine.Offset + region.BeginColumn,
region.EndColumn + 1 - region.BeginColumn);
IDocumentLine documentLine = document.GetLine(region.BeginLine);
return new WixDocumentLineSegment(documentLine.Offset + region.BeginColumn - 1,
region.EndColumn - region.BeginColumn + 1);
}
static WixDocumentLineSegment ConvertRegionToMultiLineSegment(IDocument document, DomRegion region)
@ -77,10 +77,10 @@ namespace ICSharpCode.WixBinding @@ -77,10 +77,10 @@ namespace ICSharpCode.WixBinding
int length = 0;
int startOffset = 0;
for (int line = region.BeginLine; line <= region.EndLine; ++line) {
IDocumentLine currentDocumentLine = document.GetLine(line + 1);
IDocumentLine currentDocumentLine = document.GetLine(line);
if (line == region.BeginLine) {
length += currentDocumentLine.TotalLength - region.BeginColumn;
startOffset = currentDocumentLine.Offset + region.BeginColumn;
startOffset = currentDocumentLine.Offset + region.BeginColumn - 1;
} else if (line < region.EndLine) {
length += currentDocumentLine.TotalLength;
} else {

38
src/AddIns/BackendBindings/WixBinding/Project/Src/WixDocumentReader.cs

@ -43,6 +43,11 @@ namespace ICSharpCode.WixBinding @@ -43,6 +43,11 @@ namespace ICSharpCode.WixBinding
}
}
public WixDocumentReader(string document)
: this(new StringReader(document))
{
}
public WixDocumentReader(TextReader textReader)
{
reader = new XmlTextReader(textReader);
@ -127,8 +132,8 @@ namespace ICSharpCode.WixBinding @@ -127,8 +132,8 @@ namespace ICSharpCode.WixBinding
{
// Store the column and line position since the call to GetIdFromCurrentNode will
// move to the <Dialog> Id attribute.
int line = reader.LineNumber - 1;
int column = reader.LinePosition - 2; // Take off 2 to so the '<' is located.
int line = reader.LineNumber;
int column = reader.LinePosition - 1; // Take off 1 to so the '<' is located.
if (idAttributeValue == GetIdAttributeValueFromCurrentNode()) {
return new Location(column, line);
@ -136,9 +141,12 @@ namespace ICSharpCode.WixBinding @@ -136,9 +141,12 @@ namespace ICSharpCode.WixBinding
return Location.Empty;
}
/// <summary>
/// Location line numbers are one based.
/// </summary>
public Location GetEndElementLocation(string name, string id)
{
using (reader) {
using (reader) {
bool startElementFound = false;
object elementName = reader.NameTable.Add(name);
while (reader.Read()) {
@ -154,7 +162,7 @@ namespace ICSharpCode.WixBinding @@ -154,7 +162,7 @@ namespace ICSharpCode.WixBinding
if (IsElementMatch(elementName, reader.LocalName)) {
// Take off an extra 2 from the line position so we get the
// correct column for the < tag rather than the element name.
return new Location(reader.LinePosition - 3, reader.LineNumber - 1);
return new Location(reader.LinePosition - 2, reader.LineNumber);
}
}
break;
@ -167,15 +175,12 @@ namespace ICSharpCode.WixBinding @@ -167,15 +175,12 @@ namespace ICSharpCode.WixBinding
/// <summary>
/// Gets the dialog id at the specified line.
/// </summary>
/// <param name="index">Line numbers start from zero.</param>
/// <param name="index">Line numbers start from one.</param>
public string GetDialogId(int line)
{
// Add one to line since XmlTextReader line numbers start from one.
++line;
DialogStartElement dialogStartElement = null;
using (reader) {
using (reader) {
object dialogElementName = reader.NameTable.Add("Dialog");
while (reader.Read()) {
switch (reader.NodeType) {
@ -209,6 +214,9 @@ namespace ICSharpCode.WixBinding @@ -209,6 +214,9 @@ namespace ICSharpCode.WixBinding
/// containing the start tag and the end column is the column containing the final
/// end tag marker.
/// </summary>
/// <remarks>
/// The lines and columns in the region are one based.
/// </remarks>
/// <param name="name">The name of the element.</param>
/// <param name="id">The id attribute value of the element.</param>
public DomRegion GetElementRegion(string name, string id)
@ -260,11 +268,11 @@ namespace ICSharpCode.WixBinding @@ -260,11 +268,11 @@ namespace ICSharpCode.WixBinding
Location GetEmptyElementEnd()
{
reader.ReadStartElement();
int line = reader.LineNumber - 1;
int line = reader.LineNumber;
// Take off two as we have moved passed the end tag
// Take off one as we have moved passed the end tag
// column.
int column = reader.LinePosition - 2;
int column = reader.LinePosition - 1;
return new Location(column, line);
}
@ -276,10 +284,10 @@ namespace ICSharpCode.WixBinding @@ -276,10 +284,10 @@ namespace ICSharpCode.WixBinding
Location GetEndElementEnd()
{
reader.ReadEndElement();
int line = reader.LineNumber - 1;
int line = reader.LineNumber;
// Take off two as we have moved passed the end tag column.
int column = reader.LinePosition - 2;
// Take off one as we have moved passed the end tag column.
int column = reader.LinePosition - 1;
// If ReadEndElement has moved to the start of another element
// take off one from the column value otherwise the column

16
src/AddIns/BackendBindings/WixBinding/Project/WixBinding.addin

@ -72,7 +72,7 @@ @@ -72,7 +72,7 @@
</Path>
<Path name = "/SharpDevelop/Workbench/ProjectBindings">
<ProjectBinding id = "Wix"
<ProjectBinding id = "Wix"
guid = "{CFEE4113-1246-4D54-95CB-156813CB8593}"
supportedextensions = ".wxs"
projectfileextension = ".wixproj"
@ -158,11 +158,11 @@ @@ -158,11 +158,11 @@
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "WixSetupDialogListPad"
category = "Setup"
title = "${res:ICSharpCode.WixBinding.SetupDialogListPad.Title}"
icon = "Setup.Icons.16x16.SetupDialogsPad"
class = "ICSharpCode.WixBinding.SetupDialogListPad"
<Pad id = "WixSetupDialogListPad"
category = "Setup"
title = "${res:ICSharpCode.WixBinding.SetupDialogListPad.Title}"
icon = "Setup.Icons.16x16.SetupDialogsPad"
class = "ICSharpCode.WixBinding.SetupDialogListPad"
defaultPosition = "Bottom, Hidden" />
</Path>
@ -171,7 +171,7 @@ @@ -171,7 +171,7 @@
<MenuItem id = "OpenDialog"
icon = "Icons.16x16.OpenFileIcon"
label = "${res:ProjectComponent.ContextMenu.Open}"
class = "ICSharpCode.WixBinding.OpenDialogCommand"/>
class = "ICSharpCode.WixBinding.OpenDialogCommand"/>
<MenuItem id = "ViewCode"
label = "${res:SharpDevelop.FormsDesigner.ContextMenus.ViewCodeCommand}"
icon = "Icons.16x16.FormsDesigner.ViewCode"
@ -182,7 +182,7 @@ @@ -182,7 +182,7 @@
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "WixDialogDesigner"
type = "Secondary"
class = "ICSharpCode.WixBinding.WixDialogDesignerDisplayBinding"
class = "ICSharpCode.WixBinding.WixDialogDesignerDisplayBinding"
fileNamePattern = "\.(wxs|wxi)$"/>
</Path>

25
src/AddIns/BackendBindings/WixBinding/Test/Document/GetDialogElementRegionTests.cs

@ -33,10 +33,10 @@ namespace WixBinding.Tests.Document @@ -33,10 +33,10 @@ namespace WixBinding.Tests.Document
"\t\t</UI>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
StringReader reader = new StringReader(xml);
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
DomRegion expectedRegion = new DomRegion(3, 3, 4, 11);
DomRegion expectedRegion = new DomRegion(4, 4, 5, 12);
Assert.AreEqual(expectedRegion, region);
}
@ -50,9 +50,10 @@ namespace WixBinding.Tests.Document @@ -50,9 +50,10 @@ namespace WixBinding.Tests.Document
"\t\t</UI>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
DomRegion expectedRegion = new DomRegion(3, 0, 3, 35);
DomRegion expectedRegion = new DomRegion(4, 1, 4, 36);
Assert.AreEqual(expectedRegion, region);
}
@ -66,9 +67,10 @@ namespace WixBinding.Tests.Document @@ -66,9 +67,10 @@ namespace WixBinding.Tests.Document
"\t\t</UI>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
DomRegion expectedRegion = new DomRegion(3, 0, 3, 27);
DomRegion expectedRegion = new DomRegion(4, 1, 4, 28);
Assert.AreEqual(expectedRegion, region);
}
@ -82,9 +84,10 @@ namespace WixBinding.Tests.Document @@ -82,9 +84,10 @@ namespace WixBinding.Tests.Document
"\t\t</UI>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
DomRegion expectedRegion = new DomRegion(3, 0, 3, 35);
DomRegion expectedRegion = new DomRegion(4, 1, 4, 36);
Assert.AreEqual(expectedRegion, region);
}
@ -101,9 +104,9 @@ namespace WixBinding.Tests.Document @@ -101,9 +104,9 @@ namespace WixBinding.Tests.Document
"\t\t</UI>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Dialog", "WelcomeDialog");
DomRegion expectedRegion = new DomRegion(5, 3, 6, 11);
DomRegion expectedRegion = new DomRegion(6, 4, 7, 12);
Assert.AreEqual(expectedRegion, region);
}
}

16
src/AddIns/BackendBindings/WixBinding/Test/Document/GetDialogIdAtLineTestFixture.cs

@ -21,51 +21,49 @@ namespace WixBinding.Tests.Document @@ -21,51 +21,49 @@ namespace WixBinding.Tests.Document
[TestFixture]
public class GetDialogIdAtLineTestFixture
{
StringReader reader;
string expectedDialogId = "WelcomeDialog";
WixDocumentReader wixReader;
[SetUp]
public void SetUpFixture()
{
reader = new StringReader(GetWixXml());
wixReader = new WixDocumentReader(reader);
wixReader = new WixDocumentReader(GetWixXml());
}
[Test]
public void OnDialogStartTagLine()
{
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(8));
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(9));
}
[Test]
public void StartOfDocument()
{
Assert.IsNull(wixReader.GetDialogId(0));
Assert.IsNull(wixReader.GetDialogId(1));
}
[Test]
public void LineBeforeDialogStartTag()
{
Assert.IsNull(wixReader.GetDialogId(7));
Assert.IsNull(wixReader.GetDialogId(8));
}
[Test]
public void FirstLineAfterDialogStartTag()
{
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(9));
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(10));
}
[Test]
public void DialogEndTagLine()
{
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(15));
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(16));
}
[Test]
public void FirstLineAfterDialogEndTag()
{
Assert.IsNull(wixReader.GetDialogId(16));
Assert.IsNull(wixReader.GetDialogId(17));
}
string GetWixXml()

12
src/AddIns/BackendBindings/WixBinding/Test/Document/GetDirectoryElementRegionTests.cs

@ -31,9 +31,9 @@ namespace WixBinding.Tests.Document @@ -31,9 +31,9 @@ namespace WixBinding.Tests.Document
"\t\t</Directory>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Directory", "TARGETDIR");
DomRegion expectedRegion = new DomRegion(2, 2, 3, 13);
DomRegion expectedRegion = new DomRegion(3, 3, 4, 14);
Assert.AreEqual(expectedRegion, region);
}
@ -48,9 +48,9 @@ namespace WixBinding.Tests.Document @@ -48,9 +48,9 @@ namespace WixBinding.Tests.Document
"\t\t</Directory>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Directory", "TARGETDIR");
DomRegion expectedRegion = new DomRegion(2, 2, 5, 13);
DomRegion expectedRegion = new DomRegion(3, 3, 6, 14);
Assert.AreEqual(expectedRegion, region);
}
@ -64,9 +64,9 @@ namespace WixBinding.Tests.Document @@ -64,9 +64,9 @@ namespace WixBinding.Tests.Document
"\t\t</Directory>\r\n" +
"\t</Fragment>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
DomRegion region = wixReader.GetElementRegion("Directory", "TARGETDIR");
DomRegion expectedRegion = new DomRegion(2, 2, 4, 13);
DomRegion expectedRegion = new DomRegion(3, 3, 5, 14);
Assert.AreEqual(expectedRegion, region);
}
}

12
src/AddIns/BackendBindings/WixBinding/Test/Document/GetEmptyElementDialogIdAtLineTestFixture.cs

@ -21,39 +21,37 @@ namespace WixBinding.Tests.Document @@ -21,39 +21,37 @@ namespace WixBinding.Tests.Document
[TestFixture]
public class GetEmptyElementDialogIdAtLineTestFixture
{
StringReader reader;
string expectedDialogId = "WelcomeDialog";
WixDocumentReader wixReader;
[SetUp]
public void SetUpFixture()
{
reader = new StringReader(GetWixXml());
wixReader = new WixDocumentReader(reader);
wixReader = new WixDocumentReader(GetWixXml());
}
[Test]
public void OnDialogStartTagLine()
{
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(8));
Assert.AreEqual(expectedDialogId, wixReader.GetDialogId(9));
}
[Test]
public void StartOfDocument()
{
Assert.IsNull(wixReader.GetDialogId(0));
Assert.IsNull(wixReader.GetDialogId(1));
}
[Test]
public void LineBeforeDialogStartTag()
{
Assert.IsNull(wixReader.GetDialogId(7));
Assert.IsNull(wixReader.GetDialogId(8));
}
[Test]
public void LineAfterDialogStartTag()
{
Assert.IsNull(wixReader.GetDialogId(9));
Assert.IsNull(wixReader.GetDialogId(10));
}
string GetWixXml()

6
src/AddIns/BackendBindings/WixBinding/Test/Document/GetProductEndElementLocationTests.cs

@ -33,9 +33,9 @@ namespace WixBinding.Tests.Document @@ -33,9 +33,9 @@ namespace WixBinding.Tests.Document
"\t Id='????????-????-????-????-????????????'>\r\n" +
"\t</Product>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
Location location = wixReader.GetEndElementLocation("Product", "????????-????-????-????-????????????");
Location expectedLocation = new Location(1, 6);
Location expectedLocation = new Location(2, 7);
Assert.AreEqual(expectedLocation, location);
}
@ -52,7 +52,7 @@ namespace WixBinding.Tests.Document @@ -52,7 +52,7 @@ namespace WixBinding.Tests.Document
"\t Manufacturer='#develop' \r\n" +
"\t Id='????????-????-????-????-????????????'/>\r\n" +
"</Wix>";
WixDocumentReader wixReader = new WixDocumentReader(new StringReader(xml));
WixDocumentReader wixReader = new WixDocumentReader(xml);
Location location = wixReader.GetEndElementLocation("Product", "????????-????-????-????-????????????");
Location expectedLocation = Location.Empty;
Assert.AreEqual(expectedLocation, location);

13
src/AddIns/BackendBindings/WixBinding/Test/Document/GetTwoDialogIdsFromWixDocumentTestFixture.cs

@ -34,18 +34,15 @@ namespace WixBinding.Tests.Document @@ -34,18 +34,15 @@ namespace WixBinding.Tests.Document
[TestFixtureSetUpAttribute]
public void SetUpFixture()
{
StringReader reader = new StringReader(GetWixXml());
WixDocumentReader wixReader = new WixDocumentReader(reader);
WixDocumentReader wixReader = new WixDocumentReader(GetWixXml());
dialogIds = wixReader.GetDialogIds();
welcomeDialogId = dialogIds[0];
progressDialogId = dialogIds[1];
reader = new StringReader(GetWixXml());
wixReader = new WixDocumentReader(reader);
wixReader = new WixDocumentReader(GetWixXml());
welcomeDialogLocation = wixReader.GetStartElementLocation("Dialog", welcomeDialogId);
reader = new StringReader(GetWixXml());
wixReader = new WixDocumentReader(reader);
wixReader = new WixDocumentReader(GetWixXml());
missingDialogLocation = wixReader.GetStartElementLocation("Dialog", "missingDialogId");
}
@ -70,13 +67,13 @@ namespace WixBinding.Tests.Document @@ -70,13 +67,13 @@ namespace WixBinding.Tests.Document
[Test]
public void WelcomeDialogElementLine()
{
Assert.AreEqual(8, welcomeDialogLocation.Y);
Assert.AreEqual(9, welcomeDialogLocation.Y);
}
[Test]
public void WelcomeDialogElementColumn()
{
Assert.AreEqual(3, welcomeDialogLocation.X);
Assert.AreEqual(4, welcomeDialogLocation.X);
}
[Test]

10
src/AddIns/BackendBindings/WixBinding/Test/Document/RegionToOffsetTests.cs

@ -29,7 +29,7 @@ namespace WixBinding.Tests.Document @@ -29,7 +29,7 @@ namespace WixBinding.Tests.Document
[Test]
public void SingleLineRegionConvertedToSegment()
{
DomRegion region = new DomRegion(0, 0, 0, 5);
DomRegion region = new DomRegion(1, 1, 1, 6);
document.Text = "1234567890";
WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);
@ -41,7 +41,7 @@ namespace WixBinding.Tests.Document @@ -41,7 +41,7 @@ namespace WixBinding.Tests.Document
[Test]
public void TwoLineRegionConvertedToSegment()
{
DomRegion region = new DomRegion(0, 1, 1, 0);
DomRegion region = new DomRegion(1, 2, 2, 1);
document.Text = "1234567890\r\n1234567890";
WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);
@ -53,7 +53,7 @@ namespace WixBinding.Tests.Document @@ -53,7 +53,7 @@ namespace WixBinding.Tests.Document
[Test]
public void ThreeLineRegionConvertedToSegment()
{
DomRegion region = new DomRegion(0, 2, 2, 1);
DomRegion region = new DomRegion(1, 3, 3, 2);
document.Text = "1234567890\r\n1234567890\r\n1234567890";
WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);
@ -65,7 +65,7 @@ namespace WixBinding.Tests.Document @@ -65,7 +65,7 @@ namespace WixBinding.Tests.Document
[Test]
public void ThreeLineRegionWithoutCarriageReturnConvertedToSegment()
{
DomRegion region = new DomRegion(0, 2, 2, 1);
DomRegion region = new DomRegion(1, 3, 3, 2);
document.Text = "1234567890\n1234567890\n1234567890";
WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);
@ -77,7 +77,7 @@ namespace WixBinding.Tests.Document @@ -77,7 +77,7 @@ namespace WixBinding.Tests.Document
[Test]
public void RegionWithBeginLineOnSecondLineConvertedToSegment()
{
DomRegion region = new DomRegion(1, 0, 2, 0);
DomRegion region = new DomRegion(2, 1, 3, 1);
document.Text = "1234567890\r\n1234567890\r\n1234567890";
WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);

4
src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertTextTestFixture.cs

@ -45,8 +45,8 @@ namespace WixBinding.Tests.Gui @@ -45,8 +45,8 @@ namespace WixBinding.Tests.Gui
"<new-child>\r\n" +
"</new-child>\r\n";
int line = 2;
int column = 1;
int line = 3;
int column = 2;
editor.InsertIndented(line, column, xmlToInsert);
document = textEditor.Document;

4
src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorInsertUsesTextEditorPropertiesTestFixture.cs

@ -45,8 +45,8 @@ namespace WixBinding.Tests.Gui @@ -45,8 +45,8 @@ namespace WixBinding.Tests.Gui
"<new-child>\r\n" +
"</new-child>\r\n";
int line = 2;
int column = 4;
int line = 3;
int column = 5;
editor.InsertIndented(line, column, xmlToInsert);
document = textEditor.Document;

8
src/AddIns/BackendBindings/WixBinding/Test/Gui/WixDocumentEditorReplaceTextTestFixture.cs

@ -48,12 +48,12 @@ namespace WixBinding.Tests.Gui @@ -48,12 +48,12 @@ namespace WixBinding.Tests.Gui
"<new-child>\r\n" +
"</new-child>";
int line = 1;
int column = 1;
int endLine = 2;
int line = 2;
int column = 2;
int endLine = 3;
// End column is the column containing the '>' of the </child> element.
int endColumn = 8;
int endColumn = 9;
DomRegion region = new DomRegion(line, column, endLine, endColumn);

Loading…
Cancel
Save