Last active
August 29, 2015 13:58
-
-
Save gonzalezreal/9997531 to your computer and use it in GitHub Desktop.
TGRAsyncTestHelper
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
#import <Foundation/Foundation.h> | |
#define TGR_RUNLOOP_INTERVAL 0.05 | |
#define TGR_TIMEOUT_INTERVAL 1.0 | |
#define TGR_RUNLOOP_COUNT TGR_TIMEOUT_INTERVAL / TGR_RUNLOOP_INTERVAL | |
#define TGR_CAT(x, y) x ## y | |
#define TGR_TOKCAT(x, y) TGR_CAT(x, y) | |
#define __runLoopCount TGR_TOKCAT(__runLoopCount,__LINE__) | |
#define TGRAssertEventually(a1, format...) \ | |
NSUInteger __runLoopCount = 0; \ | |
while (!(a1) && __runLoopCount < TGR_RUNLOOP_COUNT) { \ | |
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:TGR_RUNLOOP_INTERVAL]; \ | |
[NSRunLoop.currentRunLoop runUntilDate:date]; \ | |
__runLoopCount++; \ | |
} \ | |
if (__runLoopCount >= TGR_RUNLOOP_COUNT) { \ | |
XCTFail(format); \ | |
} |
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
HCRVolume * __block volume = nil; | |
[[self.client fetchVolumeWithID:@"L9fpff1b4kwC"] subscribeNext:^(id x) { | |
volume = x; | |
}]; | |
TGRAssertEventually(volume != nil, @"should complete with a response"); | |
XCTAssertTrue([volume isKindOfClass:HCRVolume.class], @"should return a single volume"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment