6

Can somebody show an example how to use Akka.Net Testkit with F# API? Both Akka.Net and F# are quite new to me so I don't know if it is even feasible or reasonable to write unit tests this way (F# API and Testkit). To be more specific, quite simply I don't know how to get access to Sys with F# API. This is what I got:

module SocketTests
open Xunit
open Akka.TestKit
open Akka.TestKit.Internal
open Akka.TestKit.Xunit2
open Akka.FSharp

type SocketTests() =
    inherit Akka.TestKit.Xunit2.TestKit()


    [<Fact>]
    let Socket_should_change_to_connected_state_when_receiving_Connect() =

Ok, now I would need to get reference to Sys for spawning something and for the life of me I can't figure it out. :-(

Any help would be much appreciated

Jukka Puranen
  • 8,026
  • 6
  • 27
  • 25
  • 2
    You would need to make your test an instance method to have access to Sys (so using `member` instead of `let`). Akka.FSharp doesn't have a dedicated testing API - if you need one you may use Akkling or just copy [Akkling.TestKit helpers](https://github.com/Horusiath/Akkling/blob/master/src/Akkling.TestKit/TestKit.fs) - it's a single file, minor type definition changes are necessary to make it working with Akka.FSharp. – Bartosz Sypytkowski Sep 20 '16 at 09:11
  • Excellent, Akkling + the TestKit helpers is just what I need. Thanks for creating it. – Jukka Puranen Sep 20 '16 at 09:22

0 Answers0