Last active
November 3, 2020 03:38
-
-
Save Horusiath/3cdb63c28a7a1b5065c7719cd8d6ec8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrapper function over TestKit.ActorOfAsTestActorRef | |
let spawnAsTestRef (tck:Tck) (props: Props<'T>) : IActorRef<'T> = | |
typed (tck.ActorOfAsTestActorRef<FunActor<'T>>(props.ToProps(), tck.TestActor) :> IActorRef) | |
[<Fact>] | |
let ``Parent should create child`` () = testDefault <| fun tck -> | |
// child actor definition | |
let child (ctx: Actor<_>) msg = ctx.Sender() <! "hello" |> ignored | |
// parent actor defintion | |
let rec parent (ctx: Actor<_>) = | |
// spawn child | |
let childRef = spawnAnonymous ctx (props (actorOf2 child)) | |
let rec loop () = actor { | |
let! msg = ctx.Receive() | |
childRef <<! msg // forward message to child | |
return loop() | |
} | |
loop () | |
let testedParent = spawnAsTestRef tck (props parent) | |
testedParent <! "this should be forwarded to the child" | |
expectMsg tck "hello" |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Akka.FSharp version: