|
|
|
@ -1,24 +1,24 @@
@@ -1,24 +1,24 @@
|
|
|
|
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
|
|
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.AvalonEdit.Search; |
|
|
|
|
using ICSharpCode.SharpDevelop.Editor.Search; |
|
|
|
|
using System; |
|
|
|
|
using ICSharpCode.AvalonEdit.Search; |
|
|
|
|
using ICSharpCode.Core; |
|
|
|
|
using ICSharpCode.NRefactory.Editor; |
|
|
|
|
using ICSharpCode.SharpDevelop.Editor.Search; |
|
|
|
|
using NUnit.Framework; |
|
|
|
|
using SearchAndReplace; |
|
|
|
|
using SearchAndReplace.Tests.Utils; |
|
|
|
|
using Rhino.Mocks; |
|
|
|
|
|
|
|
|
|
namespace SearchAndReplace.Tests |
|
|
|
|
{ |
|
|
|
|
/// <summary>
|
|
|
|
|
/// SD2-857 - The search fails to find a string if the cursor is
|
|
|
|
|
/// SD2-857 - The search fails to find a string if the cursor is
|
|
|
|
|
/// positioned at the end of the last line. For example, if the
|
|
|
|
|
/// text editor has the text:
|
|
|
|
|
/// "foo"
|
|
|
|
|
/// without the quotes and no newline after this text, then
|
|
|
|
|
/// putting the cursor at the end after the last 'o' and
|
|
|
|
|
/// opening the search dialog and doing a find next for 'foo'
|
|
|
|
|
/// putting the cursor at the end after the last 'o' and
|
|
|
|
|
/// opening the search dialog and doing a find next for 'foo'
|
|
|
|
|
/// the string is not found.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TestFixture] |
|
|
|
@ -41,31 +41,36 @@ namespace SearchAndReplace.Tests
@@ -41,31 +41,36 @@ namespace SearchAndReplace.Tests
|
|
|
|
|
SearchOptions.MatchWholeWord = false; |
|
|
|
|
|
|
|
|
|
// Create the document to be searched.
|
|
|
|
|
MockDocument doc = new MockDocument(); |
|
|
|
|
var doc = MockRepository.GenerateStub<IDocument>(); |
|
|
|
|
doc.Text = "foo"; |
|
|
|
|
doc.Stub(d => d.TextLength).Return(doc.Text.Length); |
|
|
|
|
|
|
|
|
|
var location = MockRepository.GenerateStub<SearchLocation>(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, SearchOptions.SearchTarget == SearchTarget.CurrentSelection ? SearchManager.GetActiveSelection(true) : null); |
|
|
|
|
|
|
|
|
|
location.Stub(l => l.GenerateFileList()).Return(new[] { new FileName(@"C:\Temp\test.txt") }); |
|
|
|
|
|
|
|
|
|
// Create a doc info with an initial end offset right
|
|
|
|
|
// Create a doc info with an initial end offset right
|
|
|
|
|
// at the end of the text.
|
|
|
|
|
ProvidedDocumentInformation docInfo = new ProvidedDocumentInformation(doc, @"C:\Temp\test.txt", doc.TextLength); |
|
|
|
|
|
|
|
|
|
// Search the document.
|
|
|
|
|
// result = SearchManager.FindNext(SearchOptions.CurrentFindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchMode.Normal,
|
|
|
|
|
// );
|
|
|
|
|
var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode); |
|
|
|
|
result = SearchManager.FindNext(strategy, location); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test, Ignore] |
|
|
|
|
[Test] |
|
|
|
|
public void FoundMatch() |
|
|
|
|
{ |
|
|
|
|
Assert.IsNotNull(result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test, Ignore] |
|
|
|
|
[Test] |
|
|
|
|
public void FoundTextOffset() |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(0, result.StartOffset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test, Ignore] |
|
|
|
|
[Test] |
|
|
|
|
public void FoundTextLength() |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(3, result.Length); |
|
|
|
|