2016-03-23 7 views
0

ローカルの通知を追加するアプリケーションを作成しています。 これは私のテストですOCMockito/OCHamcrestの配列にオブジェクトプロパティが含まれていることを確認します。

- (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()]; } 

これは正しく、検証は成功です。 私のUILocalNotificationオブジェクトのプロパティalertBodyにあり、フレンズの配列に含まれていないかどうかを確認する必要があります。 これには方法がありますか?

+0

「alertBody」はどのようなものになるでしょうか? '@" a "と同じですか? –

+0

このシナリオでは友人がいませんので、** alertBody **は** withoutFriends **配列のランダム値になります。 – milczi

答えて

1

私が見るのはisInです。missing from the READMEです。

[verifyCount(application, times(1)) scheduleLocalNotification:hasProperty(@"alertBody", isIn(withoutFriends))]; 
+0

ありがとう!それは素晴らしい作品です! – milczi