Created
August 6, 2015 16:10
-
-
Save jhoughjr/dcfd9a7bbf869c0695d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)cancelLocalNotificationForReminder:(ReminderVO *)reminder | |
{ | |
for(UILocalNotification* notification in [UIApplication sharedApplication].scheduledLocalNotifications) | |
{ | |
if([[notification.userInfo objectForKey:KEY_INFO_ID] isEqualToString:reminder.UUID]) | |
{ | |
[[UIApplication sharedApplication] cancelLocalNotification:notification]; | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testThat_cancelLocalNotificationForReminder_cancelsTheReminderWithAMAtchingUUID { | |
// Assert | |
NSString *testUUID = @"IMATESTREMINDERNOTIFICAITON"; | |
id mockReminder = OCMClassMock([ReminderVO class]); | |
[[[mockReminder expect] andReturn:testUUID] UUID]; | |
id mockUserInfo = OCMClassMock([NSDictionary class]); | |
id mockReminderLocalNotification = OCMClassMock([UILocalNotification class]); | |
[[[mockUserInfo expect] andReturn:mockReminder] objectForKey:testUUID]; | |
[[[mockReminderLocalNotification expect] andReturn:mockUserInfo] userInfo]; | |
id mockApplication = OCMPartialMock([UIApplication sharedApplication]); | |
NSArray *testSheduledNotifications = @[mockReminderLocalNotification]; | |
[[[mockApplication expect] andReturn:testSheduledNotifications] scheduledLocalNotifications]; | |
[[mockApplication expect] cancelLocalNotification:mockReminderLocalNotification]; | |
// Act | |
[ReminderManagerOLD cancelLocalNotificationForReminder:mockReminderLocalNotification]; | |
// Verify | |
OCMVerifyAll(mockApplication); | |
OCMVerifyAll(mockReminderLocalNotification); | |
[mockApplication stopMocking]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment