-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathQueryStringBuilderTests.cs
54 lines (42 loc) · 1.68 KB
/
QueryStringBuilderTests.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
using GridShared.Utility;
using Microsoft.Extensions.Primitives;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace GridBlazor.Tests.Utility
{
[TestClass]
public class QueryStringBuilderTests
{
private CustomQueryStringBuilder _builder;
[TestInitialize]
public void Init()
{
}
[TestMethod]
public void TestExcept()
{
QueryDictionary<StringValues> query = new QueryDictionary<StringValues>();
query.Add("key1", "value1");
query.Add("key2", "value2");
_builder = new CustomQueryStringBuilder(query);
var str1 = _builder.GetQueryStringExcept(new[] { "key1" });
Assert.AreEqual(str1, "?key2=value2");
str1 = _builder.GetQueryStringExcept(new[] { "key2" });
Assert.AreEqual(str1, "?key1=value1");
str1 = _builder.GetQueryStringExcept(new[] { "key1", "key2" });
Assert.AreEqual(str1, string.Empty);
}
[TestMethod]
public void TestWithParameter()
{
QueryDictionary<StringValues> query = new QueryDictionary<StringValues>();
query.Add("key1", "value1");
query.Add("key2", "value2");
query.Add("key3", "value3");
_builder = new CustomQueryStringBuilder(query);
var str1 = _builder.GetQueryStringWithParameter("key4", "value4");
Assert.AreEqual(str1, "?key1=value1&key2=value2&key3=value3&key4=value4");
str1 = _builder.GetQueryStringWithParameter("key4", "value4new");
Assert.AreEqual(str1, "?key1=value1&key2=value2&key3=value3&key4=value4new");
}
}
}