You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -51,7 +51,11 @@ We use single discriminated union for `Title`, `Author` and `Quantity`, this wil
51
51
After we have the basic type we can add the command to the `Commands` module in the `Contracts` project. Replace the `RegisterInventoryItem` with the following
52
52
53
53
```fsharp
54
-
| RegisterInventoryItem of Item * Quantity
54
+
| RegisterInventoryItem of RegisterInventoryItem
55
+
56
+
and RegisterInventoryItem = {
57
+
Item:Item
58
+
Quantity:Quantity }
55
59
```
56
60
57
61
The last type we need to add is the event used in the test. So add that to the `Events` module. The `EventData` definition should look like this when done:
@@ -72,14 +76,12 @@ In the `Inventory` module we have skeleton implementation of what we need. The m
72
76
If you add a break point in the `executeCommand` function you'll see that the `State` is `ItemInit`. That state is defined in `DomainTypes`, and is the state we are interested in right now since nothing has happened and the `Item` should be in its initial stage. To get the test green we need to handle the command, and to address that you need to change the implementation to this:
73
77
74
78
```fsharp
75
-
let handleAtInit (id, command) =
76
-
match command with
77
-
| RegisterInventoryItem(item, quantity) -> [ItemRegistered(item, quantity)] |> ok
78
-
| _ -> raise (exn "Implement me")
79
+
let handleAtInit (id, (command:RegisterInventoryItem)) =
80
+
[ItemRegistered(command.Item, command.Quantity)] |> ok
0 commit comments