Ich erstelle eine Anwendung, die einige lokale Benachrichtigungen hinzufügt. Dies ist mein TestOCMockito/OCHamcrest Verify-Array enthält Objekteigenschaft
- (void)testFirstLogin {
//some initials array
NSArray *withoutFriends = @[@"a", @"b", @"c", @"e", @"f"];
NSArray *withFriends = @[@"v", @"w", @"x", @"y", @"z"];
//my service which add local notifications
LocalNotificationService *service = [LocalNotificationService sharedInstance];
service.lastLoginDate = nil;
//UIApplication mock
UIApplication *application = mock([UIApplication class]);
service.applictation = application;
//method which adds notifications
[service addNotificationScheduleFirstLoginWithNoFriendsArray:withoutFriends friendsExistArray:withFriends];
//In this method I create UILocalNotification
/*
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertBody = text;
*/
//and add it to schedule
//[self.applictation scheduleLocalNotification:localNotification];
[verifyCount(application, times(1)) scheduleLocalNotification:anything()]; }
Das ist richtig und Verifikation ist der Erfolg. Aber ich muss überprüfen, ob meine UILocalNotification Objekteigenschaft alertBody in ohneFreunde Array ist. Gibt es einen Weg dafür?
Wissen Sie im Voraus, was 'alertBody' sein wird? Wie "@" ein "'? –
In diesem Szenario gibt es keine Freunde, daher weiß ich, dass ** alertBody ** ein zufälliger Wert aus dem Array ** withoutFriends ** ist. – milczi