This code is from https://github.com/logary/logary/tree/master/src/tests/Logary.Targets.ElmahIO.Tests. The code is a test for the target for ElmahIO. I have written a target for EventStore and I need to test it. I do not understand this code and I am not sure how to write my own test function. Any explanation would be appreciated.
module Program
open System
open Expecto
open Logary
open Logary.Targets
open Logary.Tests
let target =
ElmahIO.create { logId = Guid.Parse "4e4dee38-cfbe-43db-921b-69d1d6654e5b"; apiKey = "3e3b081be7c14bfdbddef052836ae55b" }
let exnMsg =
Message.event Error "Example message with exception"
|> withException Message.addExn
[<Tests>]
let tests =
testList "elmah.io tests" [
TargetBaseline.basicTests "elmah.io" target true
testList "getType" [
testCase "of non-exception message" <| fun _ ->
let msg = Message.event Info "User signed up" |> Message.setNameStr "A.B"
let typ = ElmahIO.Impl.getType msg
Expect.equal typ "A.B" "Should have name of Message as type"
testCase "of message with exception" <| fun _ ->
let typ = ElmahIO.Impl.getType exnMsg
Expect.equal typ "System.Exception" "Should have exception type as type"
testCase "formatting message captures exception details" <| fun _ ->
let str = ElmahIO.Impl.format exnMsg
Expect.stringContains str "middleWay" "Should contain parts of StackTrace."
]
]
[<EntryPoint>]
let main argv =
Tests.runTestsInAssembly defaultConfig argv
Aucun commentaire:
Enregistrer un commentaire