1
1
module Tests.ImageExport
2
2
3
+ open System.Runtime .InteropServices
3
4
open Expecto
4
5
open Plotly.NET
5
6
open Plotly.NET .ImageExport
6
7
7
8
open System
8
9
open System.IO
9
10
10
- let testBase64JPG = File.ReadAllText (__ SOURCE_ DIRECTORY__ + " /data/testBase64JPG.txt" )
11
-
12
- let testBase64PNG =
13
- File.ReadAllBytes(__ SOURCE_ DIRECTORY__ + " /data/testPNG.png" )
14
- |> Convert.ToBase64String
11
+ let readTestFilePlatformSpecific filePostfix =
12
+ if RuntimeInformation.IsOSPlatform( OSPlatform.Linux) then
13
+ let content = File.ReadAllText (__ SOURCE_ DIRECTORY__ + $" /data/linux{filePostfix}" )
14
+ content.Substring( 0 , content.Length - 1 ) // Because on Linux you're expected to newline terminate the file
15
+ else if RuntimeInformation.IsOSPlatform( OSPlatform.Windows) then
16
+ File.ReadAllText (__ SOURCE_ DIRECTORY__ + $" /data/win{filePostfix}" )
17
+ else
18
+ raise ( Exception " Running tests on the current OS is not supported :(" )
15
19
16
20
[<Tests>]
17
21
let ``Image export tests`` =
@@ -23,21 +27,25 @@ let ``Image export tests`` =
23
27
// skipping this for now, cannot make it work atm (pTestAsync -> testAsync for running it)
24
28
testList " base64 strings" [
25
29
ptestAsync " Chart.toBase64JPGStringAsync" {
30
+ let testBase64JPG = readTestFilePlatformSpecific " TestBase64JPG.txt"
31
+
26
32
let! actual = ( Chart.Point([ 1. , 1. ]) |> Chart.toBase64JPGStringAsync())
27
33
28
34
return
29
- Expect.stringContains
35
+ Expect.equal
30
36
actual
31
37
testBase64JPG
32
38
" Invalid base64 string for Chart.toBase64JPGStringAsync"
33
39
}
34
40
ptestAsync " Chart.toBase64PNGStringAsync" {
41
+ let testBase64PNG = readTestFilePlatformSpecific " TestBase64PNG.txt"
42
+
35
43
let! actual = ( Chart.Point([ 1. , 1. ]) |> Chart.toBase64PNGStringAsync())
36
44
37
45
return
38
- Expect.stringContains
46
+ Expect.equal
39
47
actual
40
- testBase64JPG
48
+ testBase64PNG
41
49
" Invalid base64 string for Chart.toBase64PNGStringAsync"
42
50
}
43
51
]
0 commit comments