-
Notifications
You must be signed in to change notification settings - Fork 112
/
MixedUnicodeWidthAndAsciiWidthCharacters.cs
57 lines (51 loc) · 1.44 KB
/
MixedUnicodeWidthAndAsciiWidthCharacters.cs
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
50
51
52
53
54
55
56
57
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace HttpMultipartParser.UnitTests.ParserScenarios
{
public class MixedUnicodeWidthAndAsciiWidthCharacters
{
private static readonly string _testData = TestUtil.TrimAllLines(
@"--boundary_.oOo._MjQ1NTU=OTk3Ng==MjcxODE=
Content-Disposition: form-data; name=""psAdTitle""
Bonjour poignée
--boundary_.oOo._MjQ1NTU=OTk3Ng==MjcxODE=--"
);
private static readonly TestData _testCase = new TestData(
_testData,
new List<ParameterPart> {
new ParameterPart("psAdTitle", "Bonjour poignée")
},
new List<FilePart>()
);
public MixedUnicodeWidthAndAsciiWidthCharacters()
{
foreach (var filePart in _testCase.ExpectedFileData)
{
filePart.Data.Position = 0;
}
}
[Fact]
public void CanHandleUnicodeWidthAndAsciiWidthCharacters()
{
using (
Stream stream = TestUtil.StringToStream(_testCase.Request, Encoding.UTF8))
{
var parser = MultipartFormDataParser.Parse(stream, Encoding.UTF8);
Assert.True(_testCase.Validate(parser));
}
}
[Fact]
public async Task CanHandleUnicodeWidthAndAsciiWidthCharactersAsync()
{
using (
Stream stream = TestUtil.StringToStream(_testCase.Request, Encoding.UTF8))
{
var parser = await MultipartFormDataParser.ParseAsync(stream, Encoding.UTF8);
Assert.True(_testCase.Validate(parser));
}
}
}
}