1
exercism fetch fsharp nucleotide-count

NucleotideCountTest.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
// This file was auto-generated based on version 1.2.0 of the canonical data.

module NucleotideCountTest

open FsUnit.Xunit
open Xunit

open NucleotideCount

[<Fact>]
let ``Empty strand`` () =
    let strand = ""
    let expected = 
        [ ('A', 0);
          ('C', 0);
          ('G', 0);
          ('T', 0) ]
        |> Map.ofList
        |> Some
    nucleotideCounts strand |> should equal expected

[<Fact(Skip = "Remove to run test")>]
let ``Can count one nucleotide in single-character input`` () =
    let strand = "G"
    let expected = 
        [ ('A', 0);
          ('C', 0);
          ('G', 1);
          ('T', 0) ]
        |> Map.ofList
        |> Some
    nucleotideCounts strand |> should equal expected

[<Fact(Skip = "Remove to run test")>]
let ``Strand with repeated nucleotide`` () =
    let strand = "GGGGGGG"
    let expected = 
        [ ('A', 0);
          ('C', 0);
          ('G', 7);
          ('T', 0) ]
        |> Map.ofList
        |> Some
    nucleotideCounts strand |> should equal expected

[<Fact(Skip = "Remove to run test")>]
let ``Strand with multiple nucleotides`` () =
    let strand = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"
    let expected = 
        [ ('A', 20);
          ('C', 12);
          ('G', 17);
          ('T', 21) ]
        |> Map.ofList
        |> Some
    nucleotideCounts strand |> should equal expected

[<Fact(Skip = "Remove to run test")>]
let ``Strand with invalid nucleotides`` () =
    let strand = "AGXXACT"
    let expected = None
    nucleotideCounts strand |> should equal expected