File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ module SqlStreamStore.FSharp.Tests.ReadTests
2+
3+ open Expecto
4+ open SqlStreamStore.FSharp
5+ open SqlStreamStore.FSharp .Tests
6+ open SqlStreamStore.Streams
7+
8+
9+ [<Tests>]
10+ let tests =
11+ testList
12+ " Read Tests"
13+ [ testAsync " Should read forward from specific stream." {
14+ let inMemStore = new SqlStreamStore.InMemoryStreamStore()
15+
16+ let appendStreamDetails : AppendStreamDetails =
17+ { streamName = " test"
18+ version = AppendVersion.NoStream }
19+
20+ let guidString1 = " 11111111-1111-1111-1111-111111111111"
21+
22+ let guidString2 = " 22222222-2222-2222-2222-222222222222"
23+
24+ let msg1 =
25+ { id = StreamMessageId.Custom( System.Guid.Parse( guidString1))
26+ type_ = " testing"
27+ jsonData = " {}"
28+ jsonMetadata = " {}" }
29+
30+ let msg2 =
31+ { id = StreamMessageId.Custom( System.Guid.Parse( guidString2))
32+ type_ = " testing"
33+ jsonData = " {}"
34+ jsonMetadata = " {}" }
35+
36+ let msgList = [ msg1; msg2 ]
37+
38+ do ! Append.appendNewMessages inMemStore appendStreamDetails msgList
39+ |> Async.Ignore
40+
41+ let readStreamDetails : ReadStreamDetails = { streamName = " test" ; version = 0 u }
42+
43+ let! readResult = Read.readFromStreamAsync inMemStore ReadingDirection.Forward readStreamDetails 10
44+
45+ readResult.Messages
46+ |> Array.sortBy ( fun msg -> msg.MessageId)
47+ |> fun sorted ->
48+ ExpectExtra.equal guidString1 ( sorted.[ 0 ]. MessageId.ToString())
49+ ExpectExtra.equal guidString2 ( sorted.[ 1 ]. MessageId.ToString())
50+ } ]
Original file line number Diff line number Diff line change 99 <ItemGroup >
1010 <Compile Include =" ExpectoExtra.fs" />
1111 <Compile Include =" AppendTests.fs" />
12+ <Compile Include =" ReadTests.fs" />
1213 <Compile Include =" Program.fs" />
1314 </ItemGroup >
1415
You can’t perform that action at this time.
0 commit comments