Skip to content

Instantly share code, notes, and snippets.

@jhoughjr
Created August 6, 2015 16:10
Show Gist options
  • Save jhoughjr/dcfd9a7bbf869c0695d1 to your computer and use it in GitHub Desktop.
Save jhoughjr/dcfd9a7bbf869c0695d1 to your computer and use it in GitHub Desktop.
+ (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;
}
}
}
- (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