Skip to content

Commit 70d721f

Browse files
committed
CSharpFriendlyAsyncOverload: add failing tests
1 parent 894f29a commit 70d721f

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

tests/FSharpLint.Core.Tests/Rules/Conventions/CSharpFriendlyAsyncOverload.fs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,40 @@ type TestConventionsCSharpFriendlyAsyncOverload() =
88
inherit TestAstNodeRuleBase.TestAstNodeRuleBase(CSharpFriendlyAsyncOverload.rule)
99

1010
[<Test>]
11-
member this.``async function must suggest friendly implementation``() =
11+
member this.``async function should have the prefix Async``() =
1212
this.Parse("""
1313
module Foo =
1414
let Bar(): Async<unit> =
1515
Async.Sleep 5""")
1616

1717
Assert.IsTrue(this.ErrorExistsAt(3, 8))
18+
19+
[<Test>]
20+
member this.``async function should have the prefix Async 2``() =
21+
this.Parse("""
22+
module Foo =
23+
let Bar(): Async<unit> =
24+
Async.Sleep 5
25+
let BarAsync(): Task<unit> =
26+
Bar() |> Async.StartAsTask""")
27+
28+
Assert.IsTrue(this.ErrorExistsAt(3, 8))
29+
30+
31+
[<Test>]
32+
member this.``async function must suggest friendly implementation``() =
33+
this.Parse("""
34+
module Foo =
35+
let AsyncBar(): Async<unit> =
36+
Async.Sleep 5""")
37+
38+
Assert.IsTrue(this.ErrorExistsAt(3, 8))
1839

1940
[<Test>]
2041
member this.``async function with friendly implementation must not have errors``() =
2142
this.Parse("""
2243
module Foo =
23-
let Bar(): Async<unit> =
44+
let AsyncBar(): Async<unit> =
2445
Async.Sleep 5
2546
let BarAsync(): Task<unit> =
2647
Bar() |> Async.StartAsTask""")
@@ -40,7 +61,7 @@ module Foo =
4061
member this.``async function must not have errors when not delcared immediately following the parent function``() =
4162
this.Parse("""
4263
module Foo =
43-
let Bar(): Async<unit> =
64+
let AsyncBar(): Async<unit> =
4465
Async.Sleep 5
4566
let RandomFunction() =
4667
()
@@ -53,13 +74,13 @@ module Foo =
5374
member this.``multiple async functions must have errors``() =
5475
this.Parse("""
5576
module Foo =
56-
let Bar(): Async<unit> =
77+
let AsyncBar(): Async<unit> =
5778
Async.Sleep 5
5879
let RandomFunction() =
5980
()
6081
let BarAsync(): Task<unit> =
6182
Bar() |> Async.StartAsTask
62-
let Foo(): Async<unit> =
83+
let AsyncFoo(): Async<unit> =
6384
Async.Sleep 10""")
6485

6586
Assert.IsTrue(this.ErrorExistsAt(9, 8))
@@ -68,13 +89,13 @@ module Foo =
6889
member this.``multiple async functions must not have errors``() =
6990
this.Parse("""
7091
module Foo =
71-
let Bar(): Async<unit> =
92+
let AsyncBar(): Async<unit> =
7293
Async.Sleep 5
7394
let RandomFunction() =
7495
()
7596
let BarAsync(): Task<unit> =
7697
Bar() |> Async.StartAsTask
77-
let Foo(): Async<unit> =
98+
let AsyncFoo(): Async<unit> =
7899
Async.Sleep 10
79100
let FooAsync(): Task<unit> =
80101
Foo() |> Async.StartAsTask""")

0 commit comments

Comments
 (0)