forked from fsprojects/FSharp.Control.TaskSeq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskSeq.DistinctUntilChanged.Tests.fs
More file actions
39 lines (30 loc) · 1.03 KB
/
TaskSeq.DistinctUntilChanged.Tests.fs
File metadata and controls
39 lines (30 loc) · 1.03 KB
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
module TaskSeq.Tests.DistinctUntilChanged
open Xunit
open FsUnit.Xunit
open FSharp.Control
//
// TaskSeq.distinctUntilChanged
//
module EmptySeq =
[<Fact>]
let ``TaskSeq-distinctUntilChanged with null source raises`` () = assertNullArg <| fun () -> TaskSeq.distinctUntilChanged null
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``TaskSeq-distinctUntilChanged has no effect`` variant = task {
do!
Gen.getEmptyVariant variant
|> TaskSeq.distinctUntilChanged
|> TaskSeq.toListAsync
|> Task.map (List.isEmpty >> should be True)
}
module Functionality =
[<Fact>]
let ``TaskSeq-distinctUntilChanged should return no consecutive duplicates`` () = task {
let ts =
[ 'A'; 'A'; 'B'; 'Z'; 'C'; 'C'; 'Z'; 'C'; 'D'; 'D'; 'D'; 'Z' ]
|> TaskSeq.ofList
let! xs = ts |> TaskSeq.distinctUntilChanged |> TaskSeq.toListAsync
xs
|> List.map string
|> String.concat ""
|> should equal "ABZCZCDZ"
}