-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRFIDListUpdaterTest.apxc
60 lines (42 loc) · 1.9 KB
/
RFIDListUpdaterTest.apxc
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
@isTest
private class RFIDListUpdaterTest {
static testMethod void onlyReturnCurrentRfidTags() {
RestContext.response = new RestResponse();
addContact('validTag', 'Yes');
addContact('expiredTag', 'No');
String result = RFIDListUpdater.getTagList();
System.assertEquals('validTag|', result);
}
static testMethod void returnPipeDelimitedTags() {
RestContext.response = new RestResponse();
addContact('validTag1', 'Yes');
addContact('validTag2', 'Yes');
String result = RFIDListUpdater.getTagList();
System.assertEquals('validTag1|validTag2|', result);
}
static testMethod void addTextPlainContentTypeToResponse() {
RestContext.response = new RestResponse();
addContact('', 'Yes');
RFIDListUpdater.getTagList();
String contentType = RestContext.response.headers.get('Content-Type');
System.assertEquals('text/plain', contentType);
}
static testmethod void emptyResponseWhenNoValidTags() {
RestContext.response = new RestResponse();
String response = RFIDListUpdater.getTagList();
System.assertEquals('', response);
}
static testmethod void shouldStripEmptyRfidTagValues() {
RestContext.response = new RestResponse();
addContact('validTag1', 'Yes');
addContact('', 'Yes');
addContact('validTag2', 'Yes');
String response = RFIDListUpdater.getTagList();
System.assertEquals('validTag1|validTag2|', response);
}
private static void addContact(String tag, String isCurrentMember) {
Contact currentMember = new Contact(Tag_ID__c=tag, Current_Member__c=isCurrentMember,
LastName='RequiredField');
insert currentMember;
}
}