-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestUtils.fs
82 lines (65 loc) · 2.56 KB
/
TestUtils.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
72
73
74
75
76
77
78
79
80
81
82
module TestUtils
open System
open Sharpino
open FSharpPlus
open SharpinoCounter
open SharpinoCounter.SharpinoCounterApi
open Sharpino.Cache
open SharpinoCounter.CounterContext
open Sharpino
open Sharpino.MemoryStorage
open Sharpino.PgStorage
open Sharpino.TestUtils
open Sharpino.Storage
open Sharpino.CommandHandler
open SharpinoCounter.CounterContextEvents
open Sharpino.KafkaReceiver
open SharpinoCounter.Counter
open Sharpino.DoubleAccountDemo.Account
let connection =
"Server=127.0.0.1;"+
"Database=es_counter;" +
"User Id=safe;"+
"Password=safe;"
let inMemoryEventStore: IEventStore<string> = MemoryStorage()
let postgresEventStore = PgEventStore(connection)
let doNothingBroker =
{
notify = None
notifyAggregate = None
}
let counterContextStorageStateViewer =
getStorageFreshStateViewer<CounterContext, CounterCountextEvents, string> postgresEventStore
let counterAggregateStorageStateViewer =
getAggregateStorageFreshStateViewer<Counter, CounterEvents, string> postgresEventStore
let counterContextMemoryStateViewer =
getStorageFreshStateViewer<CounterContext, CounterCountextEvents, string> inMemoryEventStore
let counterAggregateMemoryStateViewer =
getAggregateStorageFreshStateViewer<Counter, CounterEvents, string> inMemoryEventStore
let accountAggregateMemoryStateViewer =
getAggregateStorageFreshStateViewer<Account, AccountEvents, string> inMemoryEventStore
// let counterSubscriber =
// let result =
// try
// KafkaSubscriber.Create("localhost:9092", CounterContext.Version, CounterContext.StorageName, "sharpinoClient") |> Result.get
// with e ->
// failwith (sprintf "KafkaSubscriber.Create failed %A" e)
// result
// will remove this
// let getKafkaCounterContextState () =
// let counterViewer =
// mkKafkaViewer<CounterContext, CounterCountextEvents> counterSubscriber counterContextStorageStateViewer (ApplicationInstance.ApplicationInstance.Instance.GetGuid())
// let counterState =
// fun () ->
// counterViewer.RefreshLoop() |> ignore
// counterViewer.State()
// counterState
let Setup(eventStore: IEventStore<string>) =
StateCache<CounterContext>.Instance.Clear()
AggregateCache<Counter, string >.Instance.Clear()
eventStore.Reset CounterContext.Version CounterContext.StorageName
eventStore.Reset Counter.Version Counter.StorageName
eventStore.ResetAggregateStream Counter.Version Counter.StorageName
ApplicationInstance.ApplicationInstance.Instance.ResetGuid()
let doNothing whatever =
()