1
exercism fetch fsharp dot-dsl

DotDslTest.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
module DotDslTest

open Xunit
open FsUnit.Xunit

open DotDsl

[<Fact>]
let ``Empty graph`` () =
    let g = graph []

    nodes g |> should be Empty
    edges g |> should be Empty
    attrs g |> should be Empty
    
[<Fact(Skip = "Remove to run test")>]
let ``Graph with one node`` () =
    let g = graph [
                node "a" []
            ]            

    nodes g |> should equal [node "a" []]
    edges g |> should be Empty
    attrs g |> should be Empty
    
[<Fact(Skip = "Remove to run test")>]
let ``Graph with one node with keywords`` () =    
    let g = graph [
                node "a" [("color", "green")]
            ]            

    nodes g |> should equal [node "a" [("color", "green")]]
    edges g |> should be Empty
    attrs g |> should be Empty

[<Fact(Skip = "Remove to run test")>]
let ``Graph with one edge`` () =    
    let g = graph [
                edge "a" "b" []
            ]             

    nodes g |> should be Empty
    edges g |> should equal [edge "a" "b" []]
    attrs g |> should be Empty

[<Fact(Skip = "Remove to run test")>]
let ``Graph with one attribute`` () = 
    let g = graph [
                attr "foo" "1"
            ]             

    nodes g |> should be Empty
    edges g |> should be Empty
    attrs g |> should equal [attr "foo" "1"]

[<Fact(Skip = "Remove to run test")>]
let ``Graph with attributes`` () =    
    let g = graph [
                attr "foo" "1"
                attr "title" "Testing Attrs"
                node "a" [("color", "green")]
                node "c" []
                node "b" [("label", "Beta!")]                
                edge "b" "c" []
                edge "a" "b" [("color", "blue")]                
                attr "bar" "true"
            ]             

    nodes g |> should equal [node "a" [("color", "green")]; node "b" [("label", "Beta!")]; node "c" []]
    edges g |> should equal [edge "a" "b" [("color", "blue")]; edge "b" "c" []]
    attrs g |> should equal [attr "bar" "true"; attr "foo" "1"; attr "title" "Testing Attrs"]