Skip to content

Instantly share code, notes, and snippets.

@MattesGroeger
Created November 8, 2013 10:23
Show Gist options
  • Save MattesGroeger/7369109 to your computer and use it in GitHub Desktop.
Save MattesGroeger/7369109 to your computer and use it in GitHub Desktop.
I just re-factored this OCUnit code to Kiwi
[[[user1Dict[@"highscores"] valueForKey:@"fb_id"] should] contain:fbId_user2];
[[[user2Dict[@"highscores"] valueForKey:@"fb_id"] should] contain:fbId_user1];
NSDictionary *iphoneDictInIpadDict = nil;
NSDictionary *ipadDictInIphoneDict = nil;
for (NSDictionary *dict in user2Dict[@"highscores"])
{
STAssertTrue(dict[@"fb_id"] != nil, @"Has to contain fb_id");
if ([dict[@"fb_id"] isEqual:fbId_user1])
{
iphoneDictInIpadDict = dict;
}
}
for (NSDictionary *dict in user1Dict[@"highscores"])
{
STAssertTrue(dict[@"fb_id"] != nil, @"Has to contain fb_id");
if ([dict[@"fb_id"] isEqual:fbId_user2])
{
ipadDictInIphoneDict = dict;
}
}
STAssertTrue(iphoneDictInIpadDict != nil, @"Should have retrieved dictionary.");
STAssertTrue(ipadDictInIphoneDict != nil, @"Should have retrieved dictionary.");
@iljaiwas
Copy link

iljaiwas commented Nov 8, 2013

Even without Kiwi, you could accomplish something also as short using MACollectionUtilities:

import "MACollectionUtilities.h"

STAssertTrue (MATCH (user2Dict[@"highscores"], [[obj objectForKey:@"fb_id"] isEqualTo:fbId_user1])), @"Should have retrieved dictionary.");
STAssertTrue (MATCH (user1Dict[@"highscores"], [[obj objectForKey:@"fb_id"] isEqualTo:fbId_user2])), @"Should have retrieved dictionary.");

@MattesGroeger
Copy link
Author

Nice, thanks @iljaiwas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment