-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathHttpEncodings.fs
More file actions
49 lines (39 loc) · 1.71 KB
/
HttpEncodings.fs
File metadata and controls
49 lines (39 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module FSharp.Data.Tests.HttpEncodings
open FsUnit
open NUnit.Framework
open System.Text
open FSharp.Data
[<Test>]
let ``HttpEncodings.PostDefaultEncoding returns ISO-8859-1`` () =
HttpEncodings.PostDefaultEncoding.WebName |> should equal "iso-8859-1"
[<Test>]
let ``HttpEncodings.ResponseDefaultEncoding returns UTF-8`` () =
HttpEncodings.ResponseDefaultEncoding.WebName |> should equal "utf-8"
[<Test>]
let ``HttpEncodings.getEncoding with valid encoding name works`` () =
let utf8Encoding = HttpEncodings.getEncoding "utf-8"
utf8Encoding.WebName |> should equal "utf-8"
[<Test>]
let ``HttpEncodings.getEncoding with codepage number works`` () =
let utf8Encoding = HttpEncodings.getEncoding "65001"
utf8Encoding.WebName |> should equal "utf-8"
[<Test>]
let ``HttpEncodings.getEncoding with ASCII encoding name works`` () =
let asciiEncoding = HttpEncodings.getEncoding "ascii"
asciiEncoding.WebName |> should equal "us-ascii"
[<Test>]
let ``HttpEncodings.getEncoding with ISO-8859-1 encoding name works`` () =
let iso88591 = HttpEncodings.getEncoding "iso-8859-1"
iso88591.WebName |> should equal "iso-8859-1"
[<Test>]
let ``HttpEncodings.getEncoding with UTF-16 codepage works`` () =
let utf16 = HttpEncodings.getEncoding "1200"
utf16.WebName |> should equal "utf-16"
[<Test>]
let ``HttpEncodings.getEncoding with invalid encoding name throws`` () =
(fun () -> HttpEncodings.getEncoding "invalid-encoding-name" |> ignore)
|> should throw typeof<System.ArgumentException>
[<Test>]
let ``HttpEncodings.getEncoding with invalid codepage number throws`` () =
(fun () -> HttpEncodings.getEncoding "99999" |> ignore)
|> should throw typeof<System.ArgumentOutOfRangeException>