-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunningKoans.fs
More file actions
executable file
·94 lines (73 loc) · 2.3 KB
/
RunningKoans.fs
File metadata and controls
executable file
·94 lines (73 loc) · 2.3 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module KoansRunner.Test.RunningKoans
open FSharpKoans.Core
open NUnit.Framework
type FailureContainer() =
[<Koan>]
static member FailureKoan() =
Assert.Fail("expected failure")
type SuccessContainer() =
[<Koan>]
static member SuccessKoan() =
"FTW!"
type SomeSuccesses() =
[<Koan>]
static member One() =
"YAY"
[<Koan>]
static member Two() =
"WOOT"
type MixedBag() =
[<Koan>]
static member One() =
Assert.Fail("Game over")
[<Koan>]
static member Two() =
"OH YEAH!"
[<Test>]
let ``A failing koan returns its exception`` () =
let result =
typeof<FailureContainer>
|> KoanContainer.runKoans
|> Seq.head
let ex =
match result with
| Failure (_, ex) -> ex
| _ -> null
Assert.AreEqual("expected failure", ex.Message)
[<Test>]
let ``A failing koan returns a failure message`` () =
let result =
typeof<FailureContainer>
|> KoanContainer.runKoans
|> Seq.head
Assert.AreEqual("FailureKoan failed.", result.Message)
[<Test>]
let ``A successful koans returns a success message`` () =
let result =
typeof<SuccessContainer>
|> KoanContainer.runKoans
|> Seq.head
Assert.AreEqual("SuccessKoan passed", result.Message)
[<Test>]
let ``The outcome of all successful koans is returned`` () =
let result =
typeof<SomeSuccesses>
|> KoanContainer.runKoans
|> Seq.map (fun x -> x.Message)
|> Seq.reduce (fun x y -> x + System.Environment.NewLine + y)
let expected =
"One passed" + System.Environment.NewLine +
"Two passed"
Assert.AreEqual(expected, result)
[<Test>]
//might want to change this behavior
let ``Failed Koans don't stop the enumeration`` () =
let result =
typeof<MixedBag>
|> KoanContainer.runKoans
|> Seq.map (fun x -> x.Message)
|> Seq.reduce (fun x y -> x + System.Environment.NewLine + y)
let expected =
"One failed." + System.Environment.NewLine +
"Two passed"
Assert.AreEqual(expected, result)