-
Notifications
You must be signed in to change notification settings - Fork 1
/
FakeDataTests.m
97 lines (78 loc) · 3.26 KB
/
FakeDataTests.m
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
//
// FakeDataTests.m
// fakeevents
//
// Created by Adam Kirk on 3/9/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "FakeDataTests.h"
@implementation FakeDataTests
#if USE_APPLICATION_UNIT_TEST // all code under test is in the iPhone Application
- (void)testAppDelegate {
id yourApplicationDelegate = [[UIApplication sharedApplication] delegate];
STAssertNotNil(yourApplicationDelegate, @"UIApplication failed to find the AppDelegate");
}
#else // all code under test must be linked into the Unit Test bundle
- (void)testGenerateRandomAlarm {
for (int i = 0; i < 1000; i++) {
EKAlarm *alarm = [FEFakeData generateRandomAlarm];
STAssertTrue(alarm.relativeOffset <= 0 && alarm.relativeOffset >= -2592000, @"invalid relative offset %d", alarm.relativeOffset);
}
}
- (void)testGenerateRandomAlarms {
NSArray * array = [FEFakeData generateRandomAlarms];
STAssertTrue(array.count >= 0 && array.count < 6, @"wrong count of elements");
}
- (void)testGenerateRandomAllDay {
for (int i = 0; i < 1000; i++) {
BOOL allDay = [FEFakeData generateRandomAllDay];
STAssertTrue(allDay == YES || allDay == NO, @"all day value not valid");
}
}
- (void)testGenerateRandomAvailability {
for (int i = 0; i < 1000; i++) {
EKEventAvailability availability = [FEFakeData generateRandomAvailability];
STAssertTrue(availability == EKEventAvailabilityNotSupported ||
availability == EKEventAvailabilityBusy ||
availability == EKEventAvailabilityFree ||
availability == EKEventAvailabilityTentative ||
availability == EKEventAvailabilityUnavailable
, @"all day value not valid");
}
}
- (void)testGenerateRandomDates {
for (int i = 0; i < 1000; i++) {
NSDate *startDate = [FEFakeData generateRandomStartDate];
NSDate *endDate = [FEFakeData generateRandomEndDateGivenStartDate:startDate];
STAssertTrue([startDate timeIntervalSince1970] > 0, @"startDate was not a valid date");
STAssertTrue([endDate timeIntervalSince1970] > 0, @"endDate was not a valid date");
}
}
- (void)testGenerateRandomLocation {
for (int i = 0; i < 1000; i++) {
NSString *location = [FEFakeData generateRandomLocation];
STAssertTrue(![location isEqualToString:@""], @"Location was an empty string");
}
}
- (void)testGenerateRandomNote {
for (int i = 0; i < 1000; i++) {
NSString *note = [FEFakeData generateRandomNote];
STAssertTrue(![note isEqualToString:@""], @"Notes was an empty string");
}
}
- (void)testGenerateRandomRecurrenceRule {
for (int i = 0; i < 1000; i++) {
NSDate *startDate = [FEFakeData generateRandomStartDate];
NSDate *endDate = [FEFakeData generateRandomEndDateGivenStartDate:startDate];
EKRecurrenceRule *rule = [FEFakeData generateRandomRecurrenceRuleWithEndDate:endDate];
STAssertNotNil(rule, @"Recurrence rule should not be nil");
}
}
- (void)testGenerateRandomTitle {
for (int i = 0; i < 1000; i++) {
NSString *title = [FEFakeData generateRandomTitle];
STAssertTrue(![title isEqualToString:@""], @"Title was an empty string");
}
}
#endif
@end