forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetEncodingFromContentTypeTest.cs
More file actions
49 lines (34 loc) · 1.03 KB
/
GetEncodingFromContentTypeTest.cs
File metadata and controls
49 lines (34 loc) · 1.03 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using ServiceStack.Host.HttpListener;
namespace ServiceStack.WebHost.Endpoints.Tests.TestExistingDir
{
[TestFixture]
public class GetEncodingFromContentTypeTest
{
[Test]
public void Can_Get_Correct_Encoding()
{
var ct = "Content-Type: text/plain; charset=KOI8-R";
var encoding = ListenerRequest.GetEncoding(ct);
Assert.AreEqual("koi8-r", encoding.BodyName);
}
[Test]
public void Return_Null_When_No_Encoding()
{
var ct = "Content-Type: text/plain";
var encoding = ListenerRequest.GetEncoding(ct);
Assert.IsNull(encoding);
}
[Test]
public void Return_Null_When_Wrong_Encoding()
{
var ct = "Content-Type: text/plain; charset=ASDFG";
var encoding = ListenerRequest.GetEncoding(ct);
Assert.IsNull(encoding);
}
}
}