Commit 6ac7446e authored by Dag Brattli's avatar Dag Brattli

Test fix and cleanup

parent d39287a9
......@@ -93,7 +93,7 @@ type TestApi () =
aisResult.Value.Type |> should equal 1
[<Test>]
member _this.TestApiParseType1IsSuccess () =
member _this.``Test API parse type 1 is success`` () =
// Arrage
let input = "!BSVDM,1,1,,A,13mAwp001m0MMrjSoomG6mWT0<1h,0*16";
let mutable aisResult = ref Ais.defaultAisResult
......@@ -107,8 +107,8 @@ type TestApi () =
// Assert
result2 |> should be True
cnbResult.Value.Mmsi |> should equal 257196000
cnbResult.Value.Latitude |> should equal 6.4372683333333329
cnbResult.Value.Longitude |> should equal 62.692621666666668
cnbResult.Value.Latitude |> should equal 62.692621666666668
cnbResult.Value.Longitude |> should equal 6.4372683333333329
[<Test>]
member _this.TestApiParseType5IsSuccess () =
......@@ -134,7 +134,7 @@ type TestApi () =
savResult.Value.Mmsi |> should equal 257234000
[<Test>]
member _this.TestApiParseType1ShortThrowsException () =
member _this.``Test API parse type 1 with short data throws exception`` () =
// Arrage
let input = "!BSVDM,1,1,,A,1,0*16";
let mutable aisResult = ref Ais.defaultAisResult
......
......@@ -5,16 +5,17 @@ open FsUnit
open FParsec
open NAisParser
open NAisParser.Ais
[<TestClass>]
type TestClassType5 () =
[<SetUp>]
member this.Setup () =
member _this.Setup () =
()
[<Test>]
member this.TestBsvdmMultiFragmentIsSuccess () =
member _this.``Test BSVDM multi fragment is success`` () =
// Arrage
let input: string [] = [|
"!BSVDM,2,1,2,A,53mDDD02>EjthmLJ220HtppE>2222222222222164@G:34rdR?QSkSQDp888,0*15";
......@@ -22,8 +23,8 @@ type TestClassType5 () =
|]
let result =
input
|> Seq.map (run Ais.aisParser)
|> Seq.reduce Ais.defragment
|> Seq.map (run aisParser)
|> Seq.reduce defragment
let result2 =
match result with
......@@ -33,5 +34,27 @@ type TestClassType5 () =
Failure(a, b, c)
// Assert
result |> Ais.isSuccess |> should be True
result2 |> Ais.isSuccess |> should be True
\ No newline at end of file
result |> isSuccess |> should be True
result2 |> isSuccess |> should be True
[<Test>]
member _this.``Test BSVDM multi fragment with invalid packet is failure`` () =
// Arrage
let input: string [] = [|
"!XXXXX,2,1,2,A,53mDDD02>EjthmLJ220HtppE>2222222222222164@G:34rdR?QSkSQDp888,0*15";
"!BSVDM,2,2,2,A,88888888880,2*3F";
|]
let result =
input
|> Seq.map (run aisParser)
|> Seq.reduce defragment
let result2 =
match result with
| Success (ais, _, _) ->
run Type5.parseMessageType5 (Common.intListToBinaryString ais.Payload)
| Failure (a, b, c) ->
Failure(a, b, c)
// Assert
result |> isSuccess |> should be False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment