Skip to content

Commit 66d151f

Browse files
committed
Unit Tests for UrlEncode limit fix
1 parent 54a4d15 commit 66d151f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using RestSharp.Extensions;
7+
using Xunit;
8+
9+
namespace RestSharp.Tests
10+
{
11+
public class StringExtensionsTests
12+
{
13+
[Fact]
14+
public void UrlEncode_Throws_ArgumentNullException_For_Null_Input()
15+
{
16+
const string nullString = null;
17+
Assert.Throws<System.ArgumentNullException>(
18+
delegate
19+
{
20+
nullString.UrlEncode();
21+
});
22+
}
23+
24+
[Fact]
25+
public void UrlEncode_Returns_Correct_Length_When_Less_Than_Limit()
26+
{
27+
const int numLessThanLimit = 32766;
28+
string stringWithLimitLength = new string('*', numLessThanLimit);
29+
Assert.True(stringWithLimitLength.UrlEncode().Length == numLessThanLimit);
30+
}
31+
32+
[Fact]
33+
public void UrlEncode_Returns_Correct_Length_When_More_Than_Limit()
34+
{
35+
const int numGreaterThanLimit = 65000;
36+
string stringWithLimitLength = new string('*', numGreaterThanLimit);
37+
Assert.True(stringWithLimitLength.UrlEncode().Length == numGreaterThanLimit);
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)