๐Ÿ“ฆ sleepyfran / duets

๐Ÿ“„ PracticeSong.Tests.fs ยท 61 lines
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
61module Duets.Simulation.Tests.Songs.PracticeSong

open Test.Common
open NUnit.Framework
open FsUnit

open Duets.Entities
open Duets.Simulation.Songs.Practice

let dummyFinishedWithPracticeLevel practice =
    let (Finished(song, quality)) = dummyFinishedSong
    Finished({ song with Practice = practice }, quality)

[<Test>]
let ``practiceSong should generate SongPracticed with increase if practice level is below 100``
    ()
    =
    let result = practiceSong dummyState dummyBand dummyFinishedSong

    match result with
    | SongImproved effects ->
        effects
        |> should
            contain
            (SongPracticed(
                dummyBand,
                dummyFinishedWithPracticeLevel 20<practice>
            ))
    | _ -> failwith "Unexpected result"

[<Test>]
let ``practiceSong should allow practice level to get to 100`` () =
    let result =
        practiceSong
            dummyState
            dummyBand
            (dummyFinishedWithPracticeLevel 80<practice>)

    match result with
    | SongImproved effects ->
        effects
        |> should
            contain
            (SongPracticed(
                dummyBand,
                dummyFinishedWithPracticeLevel 100<practice>
            ))
    | _ -> failwith "Unexpected result"

[<Test>]
let ``practiceSong should return SongAlreadyImprovedToMax if level is already 100 or more``
    ()
    =
    practiceSong
        dummyState
        dummyBand
        (dummyFinishedWithPracticeLevel 100<practice>)
    |> should
        equal
        (SongAlreadyImprovedToMax(dummyFinishedWithPracticeLevel 100<practice>))