This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

RXMockObjectNullPlaceHolder → RXMockNull.

  • Loading branch information...
robrix committed Mar 23, 2010
1 parent 84f49f6 commit fe34c8ba1b597eb2a5afaa67d92e0a72afef988c
Showing with 9 additions and 9 deletions.
  1. +1 −1 RXMockObject.h
  2. +5 −5 RXMockObject.m
  3. +3 −3 RXMockObjectTests.m
View
@@ -4,7 +4,7 @@
#import <Foundation/Foundation.h>
-extern NSString const *RXMockObjectNullPlaceholder;
+extern NSString const *RXMockNull;
@interface RXMockObject : NSObject {
NSMutableDictionary *responses;
View
@@ -5,7 +5,7 @@
#import "RXMockObject.h"
#import <objc/runtime.h>
-NSString const *RXMockObjectNullPlaceholder = @"RXMockObjectNullPlaceholder";
+NSString const *RXMockNull = @"RXMockNull";
@implementation RXMockObject
@@ -51,15 +51,15 @@ -(void)setResponseObject:(id)response forSelector:(SEL)selector {
}
-(void)setResponseObject:(id)response forSelector:(SEL)selector withArgument:(id)argument {
- [self setResponseObject: response forSelector: selector withArguments: [NSArray arrayWithObject: argument ?: RXMockObjectNullPlaceholder]];
+ [self setResponseObject: response forSelector: selector withArguments: [NSArray arrayWithObject: argument ?: RXMockNull]];
}
-(void)setResponseObject:(id)response forSelector:(SEL)selector withArguments:(NSArray *)arguments {
NSMutableDictionary *responsesByArguments = [responses objectForKey: NSStringFromSelector(selector)];
if(!responsesByArguments) {
[responses setObject: (responsesByArguments = [NSMutableDictionary dictionary]) forKey: NSStringFromSelector(selector)];
}
- [responsesByArguments setObject: response ?: RXMockObjectNullPlaceholder forKey: arguments];
+ [responsesByArguments setObject: response ?: RXMockNull forKey: arguments];
}
-(id)responsesForSelector:(SEL)selector {
@@ -90,10 +90,10 @@ -(void)forwardInvocation:(NSInvocation *)invocation {
for(NSUInteger i = 2; i < invocation.methodSignature.numberOfArguments; i++) {
id argument;
[invocation getArgument: &argument atIndex: i];
- [arguments addObject: argument ?: RXMockObjectNullPlaceholder];
+ [arguments addObject: argument ?: RXMockNull];
}
id response = [self responseForSelector: invocation.selector withArguments: [arguments copy]];
- if(response == RXMockObjectNullPlaceholder) response = nil;
+ if(response == RXMockNull) response = nil;
[invocation setReturnValue: &response];
}
}
View
@@ -49,9 +49,9 @@ -(void)testAcceptsNilResponses {
[mock setResponseObject: nil forSelector: @selector(nullary)];
[mock setResponseObject: nil forSelector: @selector(unary:) withArgument: nil];
[mock setResponseObject: @"" forSelector: @selector(unary:) withArgument: @""];
- [mock setResponseObject: nil forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: RXMockObjectNullPlaceholder, RXMockObjectNullPlaceholder, nil]];
- [mock setResponseObject: @"" forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: @"", RXMockObjectNullPlaceholder, nil]];
- [mock setResponseObject: @"" forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: RXMockObjectNullPlaceholder, @"", nil]];
+ [mock setResponseObject: nil forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: RXMockNull, RXMockNull, nil]];
+ [mock setResponseObject: @"" forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: @"", RXMockNull, nil]];
+ [mock setResponseObject: @"" forSelector: @selector(binary:method:) withArguments: [NSArray arrayWithObjects: RXMockNull, @"", nil]];
RXAssertNil([mock nullary]);
RXAssertNil([mock unary: nil]);
RXAssertNotNil([mock unary: @""]);

0 comments on commit fe34c8b

Please sign in to comment.