Permalink
Browse files

Merge pull request #9 from tpesce/master

Added support for isKindOfClass: to object mocks
  • Loading branch information...
2 parents c5ad03f + e81be93 commit f8dce70434d22d20204def7a206bd0fd794bf414 @jonreid committed Jul 21, 2012
Showing with 32 additions and 0 deletions.
  1. +5 −0 Source/OCMockito/MKTObjectMock.m
  2. +27 −0 Source/Tests/MKTObjectMockTest.m
@@ -36,6 +36,11 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
#pragma mark NSObject protocol
+- (BOOL)isKindOfClass:(Class)aClass
+{
+ return [mockedClass isSubclassOfClass:aClass];
+}
+
- (BOOL)respondsToSelector:(SEL)aSelector
{
return [mockedClass instancesRespondToSelector:aSelector];
@@ -49,6 +49,33 @@ - (void)testMethodSignatureForSelectorNotInClassShouldAnswerNil
assertThat(signature, is(nilValue()));
}
+- (void)testMockShouldBeKindOfSameClass
+{
+ // given
+ NSString *mockString = mock([NSString class]);
+
+ //then
+ STAssertTrue([mockString isKindOfClass:[NSString class]], nil);
+}
+
+- (void)testMockShouldBeKindOfSubclass
+{
+ // given
+ NSString *mockString = mock([NSMutableString class]);
+
+ //then
+ STAssertTrue([mockString isKindOfClass:[NSString class]], nil);
+}
+
+- (void)testMockShouldNotBeKindOfDifferentClass
+{
+ // given
+ NSString *mockString = mock([NSString class]);
+
+ //then
+ STAssertFalse([mockString isKindOfClass:[NSArray class]], nil);
+}
+
- (void)testMockShouldRespondToKnownSelector
{
// given

0 comments on commit f8dce70

Please sign in to comment.