-
Notifications
You must be signed in to change notification settings - Fork 790
/
NavigateToSearchServiceTests.fs
76 lines (55 loc) · 2.02 KB
/
NavigateToSearchServiceTests.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// 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
module Alpha =
module Beta =
type Gamma() =
member val Delta = 3
"""
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>]
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>]
let ``operator`` () = assertResultsContain "+>" "+>"
[<Fact>]
let ``nested containers`` () =
assertResultsContain "hh.a.b.g.d" "Delta"