Browse Source
- added unit tests - moved XamlColorizer to separate thread - fixed NullReferenceException in XamlResolver git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4383 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
6 changed files with 299 additions and 45 deletions
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
|
||||
using System; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.XamlBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ExtensionsTests |
||||
{ |
||||
[Test] |
||||
public void StringReplaceTest1() |
||||
{ |
||||
string text = "Hello World!"; |
||||
int index = 0; |
||||
int length = 5; |
||||
string newText = "Bye"; |
||||
|
||||
string result = text.Replace(index, length, newText); |
||||
string expected = "Bye World!"; |
||||
|
||||
Assert.AreEqual(expected, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void StringReplaceTest2() |
||||
{ |
||||
string text = "My Hello World!"; |
||||
int index = 3; |
||||
int length = 5; |
||||
string newText = "Bye"; |
||||
|
||||
string result = text.Replace(index, length, newText); |
||||
string expected = "My Bye World!"; |
||||
|
||||
Assert.AreEqual(expected, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void StringReplaceTest3() |
||||
{ |
||||
string text = "Hello World!"; |
||||
int index = 6; |
||||
int length = 5; |
||||
string newText = "Byte"; |
||||
|
||||
string result = text.Replace(index, length, newText); |
||||
string expected = "Hello Byte!"; |
||||
|
||||
Assert.AreEqual(expected, result); |
||||
} |
||||
|
||||
[Test] |
||||
public void StringReplaceTest4() |
||||
{ |
||||
string text = "Hello World!"; |
||||
int index = 11; |
||||
int length = 1; |
||||
string newText = "?"; |
||||
|
||||
string result = text.Replace(index, length, newText); |
||||
string expected = "Hello World?"; |
||||
|
||||
Assert.AreEqual(expected, result); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlEditor; |
||||
using System; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.XamlBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveContextTests |
||||
{ |
||||
[Test] |
||||
public void ContextNoneDescriptionTest() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 2, 1); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.None, context.Description); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextNoneDescriptionTest2() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 1, 7); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.None, context.Description); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextNoneDescriptionTest3() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 3, 1); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.None, context.Description); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextAtTagDescriptionTest() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 1, 2); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.AtTag, context.Description); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextAtTagDescriptionTest2() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 2, 11); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.AtTag, context.Description); |
||||
} |
||||
|
||||
[Test] |
||||
public void ContextInTagDescriptionTest() |
||||
{ |
||||
string xaml = "<Grid>\n\t<CheckBox x:Name=\"asdf\" Background=\"Aqua\" Content=\"{x:Static Cursors.Arrow}\" />\n</Grid>"; |
||||
XamlContext context = CompletionDataHelper.ResolveContext(xaml, "", 2, 26); |
||||
|
||||
Assert.AreEqual(XamlContextDescription.InTag, context.Description); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue