Skip to content

Commit

Permalink
Tests showing how much partial mocks work so far.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed May 4, 2014
1 parent cda1ca3 commit 18a3c64
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Source/OCMockTests/OCMockObjectVerifyAfterRunTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@
#import <XCTest/XCTest.h>
#import "OCMockObject.h"

@interface TestClassForVerifyAfterRun : NSObject

- (NSString *)method1;
- (NSString *)method2;

@end

@implementation TestClassForVerifyAfterRun

- (NSString *)method1
{
id retVal = [self method2];
return retVal;
}

- (NSString *)method2
{
return @"Foo";
}

@end


@interface OCMockObjectVerifyAfterRunTests : XCTestCase

@end


@implementation OCMockObjectVerifyAfterRunTests

- (void)testDoesNotThrowWhenMethodWasInvoked
Expand All @@ -30,4 +53,24 @@ - (void)testThrowsWhenMethodWasNotInvoked
XCTAssertThrows([[mock verify] uppercaseString], @"Should have thrown an exception for a method that was not called.");
}

- (void)testDoesNotThrowWhenMethodWasInvokedOnPartialMock
{
TestClassForVerifyAfterRun *testObject = [[[TestClassForVerifyAfterRun alloc] init] autorelease];
id mock = [OCMockObject partialMockForObject:testObject];

[mock method2];

XCTAssertNoThrow([[mock verify] method2], @"Should not have thrown an exception for method that was called.");
}

//- (void)testDoesNotThrowWhenMethodWasInvokedDirectlyOnRealObject
//{
// TestClassForVerifyAfterRun *testObject = [[[TestClassForVerifyAfterRun alloc] init] autorelease];
// id mock = [OCMockObject partialMockForObject:testObject];
//
// [mock method1];
//
// XCTAssertNoThrow([[mock verify] method2], @"Should not have thrown an exception for method that was called.");
//}

@end

0 comments on commit 18a3c64

Please sign in to comment.