Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Compile Include="GoToDefinitionServiceTests.fs" />
<Compile Include="HelpContextServiceTests.fs" />
<Compile Include="QuickInfoTests.fs" />
<Compile Include="NavigateToSearchServiceTests.fs" />
<Compile Include="Hints\HintTestFramework.fs" />
<Compile Include="Hints\OptionParserTests.fs" />
<Compile Include="Hints\InlineParameterNameHintTests.fs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Editor.Tests

open Xunit
open System.Threading
open Microsoft.CodeAnalysis.Text
open Microsoft.VisualStudio.FSharp.Editor
open FSharp.Compiler.Text
open FSharp.Editor.Tests.Helpers
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo

module NavigateToSearchServiceTests =

let fileContents =
"""
module HeyHo =
let inline (+>) f c = f c

let Żółwik żwawy = ()

let ``a few words`` = 0

let one' = 1
let two'' = 2

type CamelCaseLongName = class end
"""

let sourceText = SourceText.From(fileContents)

let solution = RoslynTestHelpers.CreateSolution(fileContents)
let project = solution.Projects |> Seq.exactlyOne
let provider = MefHelpers.createExportProvider ()

let navigateToSearch pattern =
let service: IFSharpNavigateToSearchService = provider.GetExportedValue()

service
.SearchProjectAsync(
project,
[] |> Seq.toImmutableArray,
pattern,
service.KindsProvided,
CancellationToken.None
)
.Result

let assertResultsContain pattern expected =
navigateToSearch pattern
|> Seq.exists (fun i -> i.Name = expected)
|> Assert.True

[<Fact>]
let ``unicode symbols`` () = assertResultsContain "Żó" "Żółwik"

[<Fact>]
let ``capitalized camel case`` () =
assertResultsContain "CLN" "CamelCaseLongName"

[<Fact(Skip = "Old pattern matcher matches only capital letters to camel case.")>]
let ``lower camel case`` () =
assertResultsContain "cln" "CamelCaseLongName"

[<Fact>]
let ``substring`` () = assertResultsContain "ne'" "one'"

[<Fact>]
let ``backticked identifier`` () =
assertResultsContain "a few words" "a few words"

[<Fact(Skip = "Operators show logical name instead of display name.")>]
let ``operator`` () = assertResultsContain "+>" "+>"