Skip to content

Commit

Permalink
Add another initialize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
picolino committed Aug 18, 2023
1 parent 2be1a03 commit 488f543
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
11 changes: 9 additions & 2 deletions tests/Features/Initialize/Initialize.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
Feature: Initialize
As application user
I want to application starts without errors
I want to application starts properly and without errors

Scenario: Application starts without errors
Given default application configuration
When application starts
Then no errors occurs
Then no errors occurs

Scenario: If application port is not busy then remote listener and local listener both should bound on sockets
Given default application configuration
When application starts
And initial commands executes
Then remote listener is bounded
And local listener is bounded
24 changes: 19 additions & 5 deletions tests/Features/Initialize/InitializeSteps.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Skillaz.SecureChat.AcceptanceTests.InitializeSteps

open System
open Elmish
open Skillaz.SecureChat
open Skillaz.SecureChat.ChatArgs
open TickSpec
Expand All @@ -11,11 +12,24 @@ type InitializeSteps () =
[<When>]
member _.``application starts`` (args: ChatArgs) =
try
Chat.init args |> ignore
None
Chat.init args |> Result.Ok
with
| e -> Some e
| e -> Result.Error e

[<When>]
member _.``initial commands executes`` (initResult: Result<Chat.Model * Cmd<Chat.Msg>, Exception>) =
match initResult with
| Ok (model, cmd) -> Cmd.execm (model, cmd)
| Error e -> failtest <| e.ToString()

[<Then>]
member _.``remote listener is bounded`` () =
Expect.isTrue DefaultSockets.remoteListener.IsBound

[<Then>]
member _.``local listener is bounded`` () =
Expect.isTrue DefaultSockets.localListener.IsBound

[<Then>]
member _.``no errors occurs`` (exn: Exception option) =
Expect.isNone exn "Exception throws when app starts"
member _.``no errors occurs`` (initResult: Result<(Chat.Model * Cmd<Chat.Msg>), Exception>) =
Expect.isOk initResult "Exception throws when app starts"

0 comments on commit 488f543

Please sign in to comment.