Created
April 19, 2012 23:10
-
-
Save interlock/2424790 to your computer and use it in GitHub Desktop.
Mock with Stub that returns CGPoint
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
it(@"touch event mock setup", ^{ | |
UITouch *touchMock = [UITouch mock]; // this is important, it has the selector signature to cast the return type | |
CGPoint source = CGPointMake(5.0, 5.0); | |
[touchMock stub:@selector(locationInView:)andReturn:theValue(source)]; | |
NSSet *set = [NSSet setWithObject:touchMock]; | |
CGPoint pow = [touchMock locationInView:nil]; | |
[[theValue(pow.x) should] equal:5.0 withDelta:0.1]; | |
}); | |
// vs | |
it(@"touch event mock fail with generic mock", ^{ | |
id touchMock = [KWMock mock]; | |
CGPoint source = CGPointMake(5.0, 5.0); | |
[touchMock stub:@selector(locationInView:)andReturn:theValue(source)]; | |
NSSet *set = [NSSet setWithObject:touchMock]; | |
CGPoint pow = [touchMock locationInView:nil]; | |
[[theValue(pow.x) should] equal:5.0 withDelta:0.1]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment