mirror of
https://github.com/Smaug123/pulsing-server
synced 2025-10-05 23:18:40 +00:00
Initial commit of structure
This commit is contained in:
36
Test/PropertyBasedTests.fs
Normal file
36
Test/PropertyBasedTests.fs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace PulsingServer.Test
|
||||
|
||||
open PulsingServer
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
|
||||
type AgentIndex = AgentIndex of int
|
||||
type ReadIndex = ReadIndex of int
|
||||
|
||||
type Action<'info> =
|
||||
| ChangeData of 'info
|
||||
| BeginRead of AgentIndex
|
||||
| AwaitRead of ReadIndex
|
||||
|
||||
[<TestFixture>]
|
||||
module TestProperties =
|
||||
|
||||
let executeAction
|
||||
(ext : ExternalInfoProvider<'info>)
|
||||
(agents : ServerAgent<'info> array)
|
||||
((readNumber : int), (awaitingRead : Map<ReadIndex, Async<'info>>))
|
||||
(action : Action<'info>)
|
||||
=
|
||||
match action with
|
||||
| BeginRead (AgentIndex i) ->
|
||||
let mutable answer = None
|
||||
let result = ServerAgent.giveNextResponse (fun resp -> answer <- Some resp) agents.[i]
|
||||
let output =
|
||||
async {
|
||||
do! result
|
||||
return Option.get answer
|
||||
}
|
||||
ext, agents, (readNumber + 1, Map.add (ReadIndex readNumber) output awaitingRead)
|
||||
| AwaitRead index ->
|
||||
awaitingRead.[index]
|
||||
|> Async.RunSynchronously
|
Reference in New Issue
Block a user