Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import, got the first two basic functional tests passing.

  • Loading branch information...
commit b946a4d2086ebc908565f7435f706d6f31614950 0 parents
Luke Redpath authored
1  .gitattributes
@@ -0,0 +1 @@
+*.pbxproj -crlf -diff -merge
34 .gitignore
@@ -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/
16 Classes/LRMiniTestKit/LRExpectation.h
@@ -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
21 Classes/LRMiniTestKit/LRExpectationBuilder.h
@@ -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
56 Classes/LRMiniTestKit/LRExpectationBuilder.m
@@ -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
19 Classes/LRMiniTestKit/LRExpectationProxy.h
@@ -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
56 Classes/LRMiniTestKit/LRExpectationProxy.m
@@ -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
18 Classes/LRMiniTestKit/LRInvocationExpectation.h
@@ -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
57 Classes/LRMiniTestKit/LRInvocationExpectation.m
@@ -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
21 Classes/LRMiniTestKit/LRMockObject.h
@@ -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
51 Classes/LRMiniTestKit/LRMockObject.m
@@ -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
28 Classes/LRMiniTestKit/LRMockery.h
@@ -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
74 Classes/LRMiniTestKit/LRMockery.m
@@ -0,0 +1,74 @@
+//
+// LRMockery.m
+// LRMiniTestKit
+//
+// Created by Luke Redpath on 18/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import "LRMockery.h"
+#import "LRExpectationBuilder.h"
+#import "LRMockObject.h"
+
+@implementation LRMockery
+
++ (id)mockeryForSenTestCase:(SenTestCase *)testCase;
+{
+ return [self mockeryForTestCase:[LRSenTestCaseAdapter adapt:testCase]];
+}
+
++ (id)mockeryForTestCase:(id<LRTestCase>)testCase;
+{
+ return [[[self alloc] initWithTestCase:testCase] autorelease];
+}
+
+- (id)initWithTestCase:(id<LRTestCase>)aTestCase;
+{
+ if (self = [super init]) {
+ testCase = [aTestCase retain];
+ expectations = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc;
+{
+ [testCase release];
+ [expectations release];
+ [super dealloc];
+}
+
+- (id)mock:(Class)klass;
+{
+ return [LRMockObject mockForClass:klass inContext:self];
+}
+
+- (void)checking:(void (^)(id will))expectationBlock;
+{
+ expectationBlock([LRExpectationBuilder builderInContext:self]);
+}
+
+- (void)assertSatisfied;
+{
+ for (id<LRExpectation> expectation in expectations) {
+ if ([expectation isSatisfied] == NO) {
+ [testCase failWithException:[expectation failureException]];
+ }
+ }
+}
+
+- (void)addExpectation:(id<LRExpectation>)expectation;
+{
+ [expectations addObject:expectation];
+}
+
+- (void)dispatchInvocation:(NSInvocation *)invocation;
+{
+ for (id<LRExpectation> expectation in expectations) {
+ if ([expectation matches:invocation]) {
+ return [expectation invoke:invocation];
+ }
+ }
+}
+
+@end
25 Classes/LRMiniTestKit/LRTestCase.h
@@ -0,0 +1,25 @@
+//
+// LRTestCase.h
+// Mocky
+//
+// Created by Luke Redpath on 22/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@protocol LRTestCase <NSObject>
+
+- (void)failWithException:(NSException *)exception;
+
+@end
+
+@class SenTestCase;
+
+@interface LRSenTestCaseAdapter : NSObject <LRTestCase>
+{
+ SenTestCase *testCase;
+}
++ (id)adapt:(SenTestCase *)aTestCase;
+- (id)initWithSenTestCase:(SenTestCase *)aTestCase;
+@end
38 Classes/LRMiniTestKit/LRTestCase.m
@@ -0,0 +1,38 @@
+//
+// LRTestCase.m
+// Mocky
+//
+// Created by Luke Redpath on 22/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import "LRTestCase.h"
+#import <SenTestingKit/SenTestingKit.h>
+
+@implementation LRSenTestCaseAdapter
+
++ (id)adapt:(SenTestCase *)aTestCase;
+{
+ return [[[self alloc] initWithSenTestCase:aTestCase] autorelease];
+}
+
+- (id)initWithSenTestCase:(SenTestCase *)aTestCase;
+{
+ if (self = [super init]) {
+ testCase = [aTestCase retain];
+ }
+ return self;
+}
+
+- (void)dealloc;
+{
+ [testCase release];
+ [super dealloc];
+}
+
+- (void)failWithException:(NSException *)exception;
+{
+ [testCase failWithException:exception];
+}
+
+@end
20 MiniTestBundle-Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
22 MiniTestRunner-Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
466 Mocky.xcodeproj/project.pbxproj
@@ -0,0 +1,466 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ A3464E8911F279270080B46B /* libMocky.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libMocky.a */; };
+ A3464E8D11F2794A0080B46B /* SimpleExpectationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A3464E8C11F2794A0080B46B /* SimpleExpectationTests.m */; };
+ A3464F0F11F27F940080B46B /* LRMockery.m in Sources */ = {isa = PBXBuildFile; fileRef = A3464F0911F27F3B0080B46B /* LRMockery.m */; };
+ A3464F7F11F288980080B46B /* LRExpectationBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = A3464F7E11F288980080B46B /* LRExpectationBuilder.m */; };
+ A3464F9411F28A0D0080B46B /* LRExpectationProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A3464F9311F28A0D0080B46B /* LRExpectationProxy.m */; };
+ A3464FF111F292660080B46B /* LRInvocationExpectation.m in Sources */ = {isa = PBXBuildFile; fileRef = A3464FF011F292660080B46B /* LRInvocationExpectation.m */; };
+ A346500211F2937D0080B46B /* TestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A346500111F2937D0080B46B /* TestHelper.m */; };
+ A346505E11F299E60080B46B /* LRMockObject.m in Sources */ = {isa = PBXBuildFile; fileRef = A346505D11F299E60080B46B /* LRMockObject.m */; };
+ A346509011F8534C0080B46B /* LRTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = A346508F11F8534C0080B46B /* LRTestCase.m */; };
+ A34650D411F857680080B46B /* LRMockeryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A34650D311F857680080B46B /* LRMockeryTest.m */; };
+ AA747D9F0F9514B9006C5449 /* Mocky_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Mocky_Prefix.pch */; };
+ AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ A3464E8711F279230080B46B /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = D2AAC07D0554694100DB518D;
+ remoteInfo = LRMiniTestKit;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ A3464D6F11F241560080B46B /* MiniTestRunner-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MiniTestRunner-Info.plist"; sourceTree = "<group>"; };
+ A3464DCB11F242B00080B46B /* MiniTestBundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MiniTestBundle-Info.plist"; sourceTree = "<group>"; };
+ A3464E7E11F279020080B46B /* Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
+ A3464E7F11F279020080B46B /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
+ A3464E8C11F2794A0080B46B /* SimpleExpectationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleExpectationTests.m; sourceTree = "<group>"; };
+ A3464F0811F27F3B0080B46B /* LRMockery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRMockery.h; sourceTree = "<group>"; };
+ A3464F0911F27F3B0080B46B /* LRMockery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRMockery.m; sourceTree = "<group>"; };
+ A3464F7D11F288980080B46B /* LRExpectationBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRExpectationBuilder.h; sourceTree = "<group>"; };
+ A3464F7E11F288980080B46B /* LRExpectationBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRExpectationBuilder.m; sourceTree = "<group>"; };
+ A3464F9211F28A0D0080B46B /* LRExpectationProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRExpectationProxy.h; sourceTree = "<group>"; };
+ A3464F9311F28A0D0080B46B /* LRExpectationProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRExpectationProxy.m; sourceTree = "<group>"; };
+ A3464FEF11F292660080B46B /* LRInvocationExpectation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRInvocationExpectation.h; sourceTree = "<group>"; };
+ A3464FF011F292660080B46B /* LRInvocationExpectation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRInvocationExpectation.m; sourceTree = "<group>"; };
+ A346500011F2937D0080B46B /* TestHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestHelper.h; sourceTree = "<group>"; };
+ A346500111F2937D0080B46B /* TestHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestHelper.m; sourceTree = "<group>"; };
+ A346505C11F299E60080B46B /* LRMockObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRMockObject.h; sourceTree = "<group>"; };
+ A346505D11F299E60080B46B /* LRMockObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRMockObject.m; sourceTree = "<group>"; };
+ A346508911F8528F0080B46B /* LRExpectation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRExpectation.h; sourceTree = "<group>"; };
+ A346508E11F8534C0080B46B /* LRTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRTestCase.h; sourceTree = "<group>"; };
+ A346508F11F8534C0080B46B /* LRTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRTestCase.m; sourceTree = "<group>"; };
+ A34650D311F857680080B46B /* LRMockeryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRMockeryTest.m; sourceTree = "<group>"; };
+ AA747D9E0F9514B9006C5449 /* Mocky_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mocky_Prefix.pch; sourceTree = "<group>"; };
+ AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ D2AAC07E0554694100DB518D /* libMocky.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMocky.a; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ A3464E7B11F279020080B46B /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A3464E8911F279270080B46B /* libMocky.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D2AAC07C0554694100DB518D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 034768DFFF38A50411DB9C8B /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ D2AAC07E0554694100DB518D /* libMocky.a */,
+ A3464E7E11F279020080B46B /* Tests.octest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 0867D691FE84028FC02AAC07 /* LRMiniTestKit */ = {
+ isa = PBXGroup;
+ children = (
+ A3464D1311F23CC90080B46B /* Tests */,
+ 08FB77AEFE84172EC02AAC07 /* Classes */,
+ 32C88DFF0371C24200C91783 /* Other Sources */,
+ 0867D69AFE84028FC02AAC07 /* Frameworks */,
+ 034768DFFF38A50411DB9C8B /* Products */,
+ A3464D6F11F241560080B46B /* MiniTestRunner-Info.plist */,
+ A3464DCB11F242B00080B46B /* MiniTestBundle-Info.plist */,
+ A3464E7F11F279020080B46B /* Tests-Info.plist */,
+ );
+ name = LRMiniTestKit;
+ sourceTree = "<group>";
+ };
+ 0867D69AFE84028FC02AAC07 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ AACBBE490F95108600F1A2B1 /* Foundation.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 08FB77AEFE84172EC02AAC07 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ A3464D1211F23CBF0080B46B /* Mocky */,
+ );
+ path = Classes;
+ sourceTree = "<group>";
+ };
+ 32C88DFF0371C24200C91783 /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ AA747D9E0F9514B9006C5449 /* Mocky_Prefix.pch */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+ A3464D1211F23CBF0080B46B /* Mocky */ = {
+ isa = PBXGroup;
+ children = (
+ A3464F0811F27F3B0080B46B /* LRMockery.h */,
+ A3464F0911F27F3B0080B46B /* LRMockery.m */,
+ A3464F7D11F288980080B46B /* LRExpectationBuilder.h */,
+ A3464F7E11F288980080B46B /* LRExpectationBuilder.m */,
+ A3464F9211F28A0D0080B46B /* LRExpectationProxy.h */,
+ A3464F9311F28A0D0080B46B /* LRExpectationProxy.m */,
+ A3464FEF11F292660080B46B /* LRInvocationExpectation.h */,
+ A3464FF011F292660080B46B /* LRInvocationExpectation.m */,
+ A346505C11F299E60080B46B /* LRMockObject.h */,
+ A346505D11F299E60080B46B /* LRMockObject.m */,
+ A346508911F8528F0080B46B /* LRExpectation.h */,
+ A346508E11F8534C0080B46B /* LRTestCase.h */,
+ A346508F11F8534C0080B46B /* LRTestCase.m */,
+ );
+ name = Mocky;
+ path = LRMiniTestKit;
+ sourceTree = "<group>";
+ };
+ A3464D1311F23CC90080B46B /* Tests */ = {
+ isa = PBXGroup;
+ children = (
+ A346500311F293810080B46B /* Support */,
+ A3464F8911F289260080B46B /* Unit Tests */,
+ A3464F8811F289100080B46B /* Functional */,
+ );
+ path = Tests;
+ sourceTree = "<group>";
+ };
+ A3464F8811F289100080B46B /* Functional */ = {
+ isa = PBXGroup;
+ children = (
+ A3464E8C11F2794A0080B46B /* SimpleExpectationTests.m */,
+ );
+ name = Functional;
+ sourceTree = "<group>";
+ };
+ A3464F8911F289260080B46B /* Unit Tests */ = {
+ isa = PBXGroup;
+ children = (
+ A34650D311F857680080B46B /* LRMockeryTest.m */,
+ );
+ name = "Unit Tests";
+ sourceTree = "<group>";
+ };
+ A346500311F293810080B46B /* Support */ = {
+ isa = PBXGroup;
+ children = (
+ A346500011F2937D0080B46B /* TestHelper.h */,
+ A346500111F2937D0080B46B /* TestHelper.m */,
+ );
+ name = Support;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ D2AAC07A0554694100DB518D /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA747D9F0F9514B9006C5449 /* Mocky_Prefix.pch in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ A3464E7D11F279020080B46B /* Tests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = A3464E8211F279030080B46B /* Build configuration list for PBXNativeTarget "Tests" */;
+ buildPhases = (
+ A3464E7911F279020080B46B /* Resources */,
+ A3464E7A11F279020080B46B /* Sources */,
+ A3464E7B11F279020080B46B /* Frameworks */,
+ A3464E7C11F279020080B46B /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ A3464E8811F279230080B46B /* PBXTargetDependency */,
+ );
+ name = Tests;
+ productName = Tests;
+ productReference = A3464E7E11F279020080B46B /* Tests.octest */;
+ productType = "com.apple.product-type.bundle";
+ };
+ D2AAC07D0554694100DB518D /* Mocky */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Mocky" */;
+ buildPhases = (
+ D2AAC07A0554694100DB518D /* Headers */,
+ D2AAC07B0554694100DB518D /* Sources */,
+ D2AAC07C0554694100DB518D /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = Mocky;
+ productName = LRMiniTestKit;
+ productReference = D2AAC07E0554694100DB518D /* libMocky.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 0867D690FE84028FC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Mocky" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 0867D691FE84028FC02AAC07 /* LRMiniTestKit */;
+ productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ D2AAC07D0554694100DB518D /* Mocky */,
+ A3464E7D11F279020080B46B /* Tests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ A3464E7911F279020080B46B /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ A3464E7C11F279020080B46B /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ A3464E7A11F279020080B46B /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A3464E8D11F2794A0080B46B /* SimpleExpectationTests.m in Sources */,
+ A3464F7F11F288980080B46B /* LRExpectationBuilder.m in Sources */,
+ A3464F9411F28A0D0080B46B /* LRExpectationProxy.m in Sources */,
+ A3464FF111F292660080B46B /* LRInvocationExpectation.m in Sources */,
+ A346500211F2937D0080B46B /* TestHelper.m in Sources */,
+ A346505E11F299E60080B46B /* LRMockObject.m in Sources */,
+ A346509011F8534C0080B46B /* LRTestCase.m in Sources */,
+ A34650D411F857680080B46B /* LRMockeryTest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D2AAC07B0554694100DB518D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A3464F0F11F27F940080B46B /* LRMockery.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ A3464E8811F279230080B46B /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = D2AAC07D0554694100DB518D /* Mocky */;
+ targetProxy = A3464E8711F279230080B46B /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB921F08733DC00010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ COPY_PHASE_STRIP = NO;
+ DSTROOT = /tmp/LRMiniTestKit.dst;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Mocky_Prefix.pch;
+ INSTALL_PATH = /usr/local/lib;
+ PRODUCT_NAME = Mocky;
+ };
+ name = Debug;
+ };
+ 1DEB922008733DC00010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ DSTROOT = /tmp/LRMiniTestKit.dst;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = Mocky_Prefix.pch;
+ INSTALL_PATH = /usr/local/lib;
+ PRODUCT_NAME = Mocky;
+ };
+ name = Release;
+ };
+ 1DEB922308733DC00010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ OTHER_LDFLAGS = "-ObjC";
+ PREBINDING = NO;
+ SDKROOT = iphoneos4.0;
+ };
+ name = Debug;
+ };
+ 1DEB922408733DC00010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ OTHER_LDFLAGS = "-ObjC";
+ PREBINDING = NO;
+ SDKROOT = iphoneos4.0;
+ };
+ name = Release;
+ };
+ A3464E8011F279030080B46B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
+ COPY_PHASE_STRIP = NO;
+ FRAMEWORK_SEARCH_PATHS = (
+ "\"$(SDKROOT)/Developer/Library/Frameworks\"",
+ "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ );
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ INFOPLIST_FILE = "Tests-Info.plist";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ SenTestingKit,
+ "-framework",
+ UIKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = Tests;
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Debug;
+ };
+ A3464E8111F279030080B46B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ FRAMEWORK_SEARCH_PATHS = (
+ "\"$(SDKROOT)/Developer/Library/Frameworks\"",
+ "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ );
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ INFOPLIST_FILE = "Tests-Info.plist";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ SenTestingKit,
+ "-framework",
+ UIKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = Tests;
+ WRAPPER_EXTENSION = octest;
+ ZERO_LINK = NO;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Mocky" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB921F08733DC00010E9CD /* Debug */,
+ 1DEB922008733DC00010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Mocky" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB922308733DC00010E9CD /* Debug */,
+ 1DEB922408733DC00010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ A3464E8211F279030080B46B /* Build configuration list for PBXNativeTarget "Tests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A3464E8011F279030080B46B /* Debug */,
+ A3464E8111F279030080B46B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
+}
7 Mocky_Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
30 Scripts/RunTests.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+export DYLD_ROOT_PATH="$SDKROOT"
+export DYLD_FRAMEWORK_PATH="$CONFIGURATION_BUILD_DIR"
+export IPHONE_SIMULATOR_ROOT="$SDKROOT"
+
+# export MallocScribble=YES
+# export MallocPreScribble=YES
+# export MallocGuardEdges=YES
+# export MallocStackLogging=YES
+# export MallocStackLoggingNoCompact=YES
+#
+# export NSDebugEnabled=YES
+# export NSZombieEnabled=YES
+# export NSDeallocateZombies=NO
+# export NSHangOnUncaughtException=YES
+# export NSAutoreleaseFreedObjectCheckEnabled=YES
+
+"$TARGET_BUILD_DIR/$EXECUTABLE_PATH" -RegisterForSystemEvents
+RETVAL=$?
+
+if [ -n "$WRITE_JUNIT_XML" ]; then
+ MY_TMPDIR=`/usr/bin/getconf DARWIN_USER_TEMP_DIR`
+ RESULTS_DIR="${MY_TMPDIR}test-results"
+
+ if [ -d "$RESULTS_DIR" ]; then
+ `$CP -r "$RESULTS_DIR" "$BUILD_DIR" && rm -r "$RESULTS_DIR"`
+ fi
+fi
+
+exit $RETVAL
20 Tests-Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
83 Tests/LRMockeryTest.m
@@ -0,0 +1,83 @@
+//
+// LRMockeryTest.m
+// Mocky
+//
+// Created by Luke Redpath on 22/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import "TestHelper.h"
+#import "LRExpectation.h"
+#import "LRMockery.h"
+
+@interface FailingExpectation : NSObject <LRExpectation>
+{}
+@end
+
+@implementation FailingExpectation
+
+- (BOOL)isSatisfied
+{
+ return NO;
+}
+
+- (NSException *)failureException;
+{
+ return [NSException exceptionWithName:@"FailingExpectation" reason:@"always fails" userInfo:nil];
+}
+
+@end
+
+@interface PassingExpectation : NSObject <LRExpectation>
+{}
+@end
+
+@implementation PassingExpectation
+
+- (BOOL)isSatisfied;
+{
+ return YES;
+}
+
+- (NSException *)failureException;
+{
+ return nil;
+}
+
+@end
+
+@interface LRMockeryTest : SenTestCase
+{
+ MockTestCase *testCase;
+ LRMockery *mockery;
+}
+@end
+
+@implementation LRMockeryTest
+
+- (void)setUp;
+{
+ testCase = [[MockTestCase alloc] init];
+ mockery = [[LRMockery alloc] initWithTestCase:testCase];
+}
+
+#pragma mark -
+#pragma mark LRMockery tests
+
+- (void)testTriggersNoTestFailuresWhenAllExpectationsPass;
+{
+ [mockery addExpectation:[[PassingExpectation new] autorelease]];
+ [mockery assertSatisfied];
+
+ STAssertTrue([testCase numberOfFailures] == 0, @"Expected 0 failures, got %d.", [testCase numberOfFailures]);
+}
+
+- (void)testTriggersTestFailureForFailingExpectation;
+{
+ [mockery addExpectation:[[FailingExpectation new] autorelease]];
+ [mockery assertSatisfied];
+
+ STAssertTrue([testCase numberOfFailures] == 1, @"Expected 1 failure, got %d.", [testCase numberOfFailures]);
+}
+
+@end
65 Tests/SimpleExpectationTests.m
@@ -0,0 +1,65 @@
+//
+// ExampleTests.m
+// LRMiniTestKit
+//
+// Created by Luke Redpath on 18/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import "TestHelper.h"
+#import "LRMockery.h"
+#import "LRTestCase.h"
+#import "LRExpectationBuilder.h"
+
+@interface Workhorse : NSObject
+{}
+- (void)doSomething;
+@end
+
+@implementation Workhorse;
+- (void)doSomething {}
+@end
+
+@interface MockeryTests : SenTestCase
+{
+ LRMockery *mockery;
+ MockTestCase *testCase;
+}
+@end
+
+@implementation MockeryTests
+
+- (void)setUp;
+{
+ testCase = [MockTestCase new];
+ mockery = [LRMockery mockeryForTestCase:testCase];
+}
+
+- (void)testCanExpectSingleMethodCallAndPass;
+{
+ Workhorse *workhorse = [mockery mock:[Workhorse class]];
+
+ [mockery checking:^(LRExpectationBuilder *will){
+ [[will expect:workhorse] doSomething];
+ }];
+
+ [workhorse doSomething];
+ [mockery assertSatisfied];
+
+ STAssertTrue([testCase numberOfFailures] == 0, @"expected zero failures, got %d.", [testCase numberOfFailures]);
+}
+
+- (void)testCanExpectSingleMethodCallAndFail;
+{
+ Workhorse *workhorse = [mockery mock:[Workhorse class]];
+
+ [mockery checking:^(LRExpectationBuilder *will){
+ [[will expect:workhorse] doSomething];
+ }];
+
+ [mockery assertSatisfied];
+
+ STAssertTrue([testCase numberOfFailures] == 1, @"expected 1 failure, got %d.", [testCase numberOfFailures]);
+}
+
+@end
22 Tests/TestHelper.h
@@ -0,0 +1,22 @@
+//
+// TestHelper.h
+// LRMiniTestKit
+//
+// Created by Luke Redpath on 18/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <SenTestingKit/SenTestingKit.h>
+#import "LRTestCase.h"
+
+@interface NSInvocation (LRAdditions)
++ (NSInvocation *)invocationForSelector:(SEL)selector onClass:(Class)aClass;
+@end
+
+@interface MockTestCase : NSObject <LRTestCase>
+{
+ NSMutableArray *failures;
+}
+- (NSUInteger)numberOfFailures;
+@end
49 Tests/TestHelper.m
@@ -0,0 +1,49 @@
+//
+// TestHelper.m
+// LRMiniTestKit
+//
+// Created by Luke Redpath on 18/07/2010.
+// Copyright 2010 LJR Software Limited. All rights reserved.
+//
+
+#import "TestHelper.h"
+
+@implementation NSInvocation (LRAdditions)
+
++ (NSInvocation *)invocationForSelector:(SEL)selector onClass:(Class)aClass;
+{
+ NSMethodSignature *signature = [aClass instanceMethodSignatureForSelector:selector];
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
+ [invocation setSelector:selector];
+ return invocation;
+}
+
+@end
+
+@implementation MockTestCase
+
+- (id)init
+{
+ if (self = [super init]) {
+ failures = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc;
+{
+ [failures release];
+ [super dealloc];
+}
+
+- (void)failWithException:(NSException *)anException;
+{
+ [failures addObject:anException];
+}
+
+- (NSUInteger)numberOfFailures;
+{
+ return [failures count];
+}
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.