Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Encapsulating data representation and renaming ivars

  • Loading branch information...
commit ee364b3128b4a8537fa547a2183670c1b2e45185 1 parent cf47507
@hammerdr authored
Showing with 19 additions and 14 deletions.
  1. +2 −2 Framework/OJMoq/OJMoq.j
  2. +17 −12 Framework/OJMoq/OJMoqSelector.j
View
4 Framework/OJMoq/OJMoq.j
@@ -118,13 +118,13 @@ function __ojmoq_incrementNumberOfCalls(anInvocation, _selectors)
withArguments:[anInvocation userArguments]] in:_selectors];
if(theSelector)
{
- [theSelector setTimesCalled:[theSelector timesCalled]+1];
+ [theSelector call];
}
else
{
var aNewSelector = [[OJMoqSelector alloc] initWithName:sel_getName([anInvocation selector])
withArguments:[anInvocation userArguments]];
- [aNewSelector setTimesCalled:1];
+ [aNewSelector call];
[_selectors addObject:aNewSelector];
}
}
View
29 Framework/OJMoq/OJMoqSelector.j
@@ -3,10 +3,10 @@
@implementation OJMoqSelector : CPObject
{
- CPString _name @accessors(property=name, readonly);
- CPNumber _timesCalled @accessors(property=timesCalled);
- id _returnValue @accessors(property=returnValue);
- CPArray _arguments @accessors(property=arguments);
+ CPString name @accessors(readonly);
+ CPNumber timesCalled @accessors(readonly);
+ id returnValue @accessors;
+ CPArray arguments @accessors;
}
+ (OJMoqSelector)find:(OJMoqSelector)aSelector in:(CPArray)selectors
@@ -18,25 +18,30 @@
{
if(self = [super init])
{
- _name = aName;
- _arguments = someArguments;
- _timesCalled = 0;
- _returnValue = [[CPObject alloc] init];
+ name = aName;
+ arguments = someArguments;
+ timesCalled = 0;
+ returnValue = [[CPObject alloc] init];
}
return self;
}
+- (void)call
+{
+ timesCalled = timesCalled + 1;
+}
+
- (BOOL)equals:(OJMoqSelector)anotherSelector
{
- if(_name != [anotherSelector name])
+ if(name != [anotherSelector name])
{
return NO;
}
// If no arguments are specified, then we don't care.
- if([_arguments count] > 0 && [[anotherSelector arguments] count] > 0)
+ if([arguments count] > 0 && [[anotherSelector arguments] count] > 0)
{
- if (![_arguments isEqualToArray:[anotherSelector arguments]])
+ if (![arguments isEqualToArray:[anotherSelector arguments]])
{
return NO;
}
@@ -47,7 +52,7 @@
- (CPComparisonResult)compareTimesCalled:(CPNumber)anotherNumber
{
- return [_timesCalled compare:anotherNumber];
+ return [timesCalled compare:anotherNumber];
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.