forked from anthonyreilly/NetCoreForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeaderFormatterTest.cs
116 lines (82 loc) · 3.35 KB
/
HeaderFormatterTest.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.Linq;
using NetCoreForce.Client;
using Xunit;
namespace NetCoreForce.Client.Tests
{
public class HeaderFormatterTest
{
[Fact]
public void IfModifiedSinceHeader()
{
DateTimeOffset date = new DateTimeOffset(2015, 3, 23, 0, 0, 0, 0, new TimeSpan(0));
Dictionary<string, string> customHeaders = HeaderFormatter.IfModifiedSince(date);
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("If-Modified-Since: Mon, 23 Mar 2015 00:00:00 GMT", result);
}
[Fact]
public void QueryOptionsHeader()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceQueryOptions(1000);
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Query-Options: batchSize=1000", result);
}
[Fact]
public void QueryOptionsHeaderMaxException()
{
Assert.Throws<ArgumentException>(() =>
{
var customHeaders = HeaderFormatter.SforceQueryOptions(2001);
});
}
[Fact]
public void QueryOptionsHeaderMinException()
{
Assert.Throws<ArgumentException>(() =>
{
var customHeaders = HeaderFormatter.SforceQueryOptions(0);
});
}
[Fact]
public void CallOptionsHeaderWithDefaultParameters()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceCallOptions();
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Call-Options: client=ForceClient", result);
}
[Fact]
public void CallOptionsHeaderWithClientParameter()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceCallOptions("Test");
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Call-Options: client=Test", result);
}
[Fact]
public void CallOptionsHeaderWithDefaultNamespaceParameter()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceCallOptions(defaultNamespace: "Test");
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Call-Options: client=ForceClient, defaultNamespace=Test", result);
}
[Fact]
public void AutoAssignHeader()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceAutoAssign(false);
Assert.Single(customHeaders);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Auto-Assign: FALSE", result);
}
}
}