forked from anthonyreilly/NetCoreForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeaderFormatterTest.cs
74 lines (55 loc) · 2.03 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
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.Equal(1, customHeaders.Count);
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.Equal(1, customHeaders.Count);
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 AutoAssignHeader()
{
Dictionary<string, string> customHeaders = HeaderFormatter.SforceAutoAssign(false);
Assert.Equal(1, customHeaders.Count);
var header = customHeaders.First();
string result = string.Format("{0}: {1}", header.Key, header.Value);
Assert.Equal("Sforce-Auto-Assign: FALSE", result);
}
}
}