๐Ÿ“ฆ sleepyfran / duets

๐Ÿ“„ State.Inventory.Tests.fs ยท 40 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
40module Duets.Simulation.Tests.State.Inventory

open FsUnit
open NUnit.Framework
open Test.Common

open Duets.Entities
open Duets.Simulation

let private dummyMerch =
    { Brand = "DuetsMerch"
      Name = "T-shirt"
      Properties = [ Wearable TShirt ] }

[<Test>]
let ``ItemAddedToBandInventory adds the item to the inventory`` () =
    let state =
        ItemAddedToBandInventory(dummyBand, dummyMerch, 200<quantity>)
        |> State.Root.applyEffect dummyState

    Queries.Inventory.band dummyBand.Id state
    |> Map.find dummyMerch
    |> should equal 200<quantity>

[<Test>]
let ``ItemAddedToInventory sums the new quantity to the previous if the item was already in the map``
    ()
    =
    let state =
        ItemAddedToBandInventory(dummyBand, dummyMerch, 200<quantity>)
        |> State.Root.applyEffect dummyState

    let state =
        ItemAddedToBandInventory(dummyBand, dummyMerch, 100<quantity>)
        |> State.Root.applyEffect state

    Queries.Inventory.band dummyBand.Id state
    |> Map.find dummyMerch
    |> should equal 300<quantity>