Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import, got the first two basic functional tests passing.
- Loading branch information
0 parents
commit b946a4d
Showing
25 changed files
with
1,299 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
*.pbxproj -crlf -diff -merge |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
# Mac OS X Finder and whatnot | |||
.DS_Store | |||
|
|||
# XCode (and ancestors) per-user config (very noisy, and not relevant) | |||
*.mode1 | |||
*.mode1v3 | |||
*.mode2v3 | |||
*.perspective | |||
*.perspectivev3 | |||
*.pbxuser | |||
|
|||
|
|||
# Generated files | |||
VersionX-revision.h | |||
|
|||
|
|||
# build products | |||
build/ | |||
*.[oa] | |||
|
|||
# Other source repository archive directories (protects when importing) | |||
.hg | |||
.svn | |||
CVS | |||
|
|||
|
|||
# automatic backup files | |||
*~.nib | |||
*.swp | |||
*~ | |||
*(Autosaved).rtfd/ | |||
Backup[ ]of[ ]*.pages/ | |||
Backup[ ]of[ ]*.key/ | |||
Backup[ ]of[ ]*.numbers/ |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
// | |||
// LRExpectation.h | |||
// Mocky | |||
// | |||
// Created by Luke Redpath on 22/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <UIKit/UIKit.h> | |||
|
|||
@protocol LRExpectation | |||
- (BOOL)matches:(NSInvocation *)invocation; | |||
- (void)invoke:(NSInvocation *)invocation; | |||
- (BOOL)isSatisfied; | |||
- (NSException *)failureException; | |||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
// | |||
// LRExpectationBuilder.h | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
|
|||
@class LRMockObject; | |||
@class LRMockery; | |||
|
|||
@interface LRExpectationBuilder : NSObject { | |||
LRMockery *mockery; | |||
Class mockedClass; | |||
} | |||
+ (id)builderInContext:(LRMockery *)context; | |||
- (id)initWithMockery:(LRMockery *)aMockery; | |||
- (id)expect:(id)mockObject; | |||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
// | |||
// LRExpectationBuilder.m | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import "LRExpectationBuilder.h" | |||
#import "LRMockObject.h" | |||
#import "LRMockery.h" | |||
#import "LRInvocationExpectation.h" | |||
|
|||
@implementation LRExpectationBuilder | |||
|
|||
+ (id)builderInContext:(LRMockery *)context; | |||
{ | |||
return [[[self alloc] initWithMockery:context] autorelease]; | |||
} | |||
|
|||
- (id)initWithMockery:(LRMockery *)aMockery; | |||
{ | |||
if (self = [super init]) { | |||
mockery = [aMockery retain]; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void)dealloc; | |||
{ | |||
[mockery release]; | |||
[super dealloc]; | |||
} | |||
|
|||
- (id)expect:(id)mockObject; | |||
{ | |||
mockedClass = [(LRMockObject *)mockObject mockedClass]; | |||
return self; | |||
} | |||
|
|||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel | |||
{ | |||
return [mockedClass instanceMethodSignatureForSelector:sel]; | |||
} | |||
|
|||
- (BOOL)respondsToSelector:(SEL)aSelector | |||
{ | |||
return [mockedClass instancesRespondToSelector:aSelector]; | |||
} | |||
|
|||
- (void)forwardInvocation:(NSInvocation *)invocation | |||
{ | |||
[mockery addExpectation:[LRInvocationExpectation expectationWithInvocation:invocation]]; | |||
} | |||
|
|||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
// | |||
// LRExpectationProxy.h | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
|
|||
|
|||
@interface LRExpectationProxy : NSProxy { | |||
Class proxiedClass; | |||
NSMutableArray *expectations; | |||
} | |||
+ (id)proxyForClass:(Class)aClass; | |||
- (id)initWithClass:(Class)aClass; | |||
- (BOOL)hasExpectationMatchingInvocation:(NSInvocation *)invocation; | |||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
// | |||
// LRExpectationProxy.m | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import "LRExpectationProxy.h" | |||
#import "LRInvocationExpectation.h" | |||
|
|||
@implementation LRExpectationProxy | |||
|
|||
+ (id)proxyForClass:(Class)aClass; | |||
{ | |||
return [[[self alloc] initWithClass:aClass] autorelease]; | |||
} | |||
|
|||
- (id)initWithClass:(Class)aClass; | |||
{ | |||
proxiedClass = aClass; | |||
expectations = [[NSMutableArray alloc] init]; | |||
|
|||
return self; | |||
} | |||
|
|||
- (void)dealloc; | |||
{ | |||
[expectations release]; | |||
[super dealloc]; | |||
} | |||
|
|||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel | |||
{ | |||
return [proxiedClass instanceMethodSignatureForSelector:sel]; | |||
} | |||
|
|||
- (void)forwardInvocation:(NSInvocation *)invocation | |||
{ | |||
[expectations addObject:[LRInvocationExpectation expectationWithInvocation:invocation]]; | |||
} | |||
|
|||
- (BOOL)respondsToSelector:(SEL)aSelector | |||
{ | |||
return [proxiedClass instancesRespondToSelector:aSelector]; | |||
} | |||
|
|||
- (BOOL)hasExpectationMatchingInvocation:(NSInvocation *)invocation; | |||
{ | |||
for (LRInvocationExpectation *expectation in expectations) { | |||
if ([expectation matches:invocation]) return YES; | |||
} | |||
return NO; | |||
} | |||
|
|||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
// | |||
// LRInvocationExpectation.h | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
#import "LRExpectation.h" | |||
|
|||
@interface LRInvocationExpectation : NSObject <LRExpectation> { | |||
NSInvocation *expectedInvocation; | |||
NSUInteger numberOfInvocations; | |||
} | |||
+ (id)expectationWithInvocation:(NSInvocation *)anInvocation; | |||
- (id)initWithInvocation:(NSInvocation *)anInvocation; | |||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
// | |||
// LRInvocationExpectation.m | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import "LRInvocationExpectation.h" | |||
|
|||
|
|||
@implementation LRInvocationExpectation | |||
|
|||
+ (id)expectationWithInvocation:(NSInvocation *)anInvocation; | |||
{ | |||
return [[[self alloc] initWithInvocation:anInvocation] autorelease]; | |||
} | |||
|
|||
- (id)initWithInvocation:(NSInvocation *)anInvocation; | |||
{ | |||
if (self = [super init]) { | |||
expectedInvocation = [anInvocation retain]; | |||
numberOfInvocations = 0; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void)dealloc; | |||
{ | |||
[expectedInvocation release]; | |||
[super dealloc]; | |||
} | |||
|
|||
- (BOOL)matches:(NSInvocation *)invocation; | |||
{ | |||
if ([invocation selector] != [expectedInvocation selector]) { | |||
return NO; | |||
} | |||
return YES; | |||
} | |||
|
|||
- (void)invoke:(NSInvocation *)invocation | |||
{ | |||
numberOfInvocations++; | |||
} | |||
|
|||
- (BOOL)isSatisfied; | |||
{ | |||
return numberOfInvocations > 0; | |||
} | |||
|
|||
- (NSException *)failureException; | |||
{ | |||
return [NSException exceptionWithName:@"test failure" reason:@"just testing" userInfo:nil]; | |||
} | |||
|
|||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
// | |||
// LRMockObject.h | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
|
|||
@class LRMockery; | |||
|
|||
@interface LRMockObject : NSObject { | |||
Class mockedClass; | |||
LRMockery *context; | |||
} | |||
@property (nonatomic, readonly) Class mockedClass; | |||
|
|||
+ (id)mockForClass:(Class)aClass inContext:(LRMockery *)mockery; | |||
- (id)initWithClass:(Class)aClass context:(LRMockery *)mockery; | |||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
// | |||
// LRMockObject.m | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import "LRMockObject.h" | |||
#import "LRMockery.h" | |||
|
|||
@implementation LRMockObject | |||
|
|||
@synthesize mockedClass; | |||
|
|||
+ (id)mockForClass:(Class)aClass inContext:(LRMockery *)mockery; | |||
{ | |||
return [[[self alloc] initWithClass:aClass context:mockery] autorelease]; | |||
} | |||
|
|||
- (id)initWithClass:(Class)aClass context:(LRMockery *)mockery; | |||
{ | |||
if (self = [super init]) { | |||
mockedClass = aClass; | |||
context = [mockery retain]; | |||
} | |||
return self; | |||
} | |||
|
|||
- (void)dealloc; | |||
{ | |||
[context release]; | |||
[super dealloc]; | |||
} | |||
|
|||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel | |||
{ | |||
return [mockedClass instanceMethodSignatureForSelector:sel]; | |||
} | |||
|
|||
- (BOOL)respondsToSelector:(SEL)aSelector | |||
{ | |||
return [mockedClass instancesRespondToSelector:aSelector]; | |||
} | |||
|
|||
- (void)forwardInvocation:(NSInvocation *)invocation | |||
{ | |||
[context dispatchInvocation:invocation]; | |||
} | |||
|
|||
@end |
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
// | |||
// LRMockery.h | |||
// LRMiniTestKit | |||
// | |||
// Created by Luke Redpath on 18/07/2010. | |||
// Copyright 2010 LJR Software Limited. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
#import "LRExpectation.h" | |||
#import "LRTestCase.h" | |||
|
|||
@class LRExpectationBuilder; | |||
@class SenTestCase; | |||
|
|||
@interface LRMockery : NSObject { | |||
NSMutableArray *expectations; | |||
id<LRTestCase> testCase; | |||
} | |||
+ (id)mockeryForSenTestCase:(SenTestCase *)testCase; | |||
+ (id)mockeryForTestCase:(id<LRTestCase>)testCase; | |||
- (id)initWithTestCase:(id<LRTestCase>)aTestCase; | |||
- (id)mock:(Class)klass; | |||
- (void)checking:(void (^)(LRExpectationBuilder *will))expectationBlock; | |||
- (void)addExpectation:(id<LRExpectation>)expectation; | |||
- (void)assertSatisfied; | |||
- (void)dispatchInvocation:(NSInvocation *)invocation; | |||
@end |
Oops, something went wrong.