5 // Created by Wincent Colaiuta on 10 February 2006.
7 // Copyright 2006-2007 Wincent Colaiuta.
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #import "WOClassMockTests.h"
24 @implementation WOClassMockTests
26 - (void)testInitWithClass
29 WOClassMock *mock = nil;
31 // should throw if passed NULL
32 mock = [WOClassMock alloc];
33 WO_TEST_THROWS([mock initWithClass:NULL]);
35 // should throw if passed non-class pointer
36 mock = [WOClassMock alloc];
37 WO_TEST_THROWS([mock initWithClass:(Class)self]);
39 // otherwise should work
40 WO_TEST_DOES_NOT_THROW([[WOClassMock alloc] initWithClass:[self class]]);
42 // should throw if passed a meta class
43 Class class = [NSString class];
44 Class metaclass = object_getClass(class);
45 mock = [WOClassMock alloc];
46 WO_TEST_THROWS([mock initWithClass:metaclass]);
51 // should work with class methods
52 id mock = [WOClassMock mockForClass:[NSString class]];
53 WO_TEST_DOES_NOT_THROW([[mock accept] stringWithString:@"foo"]);
54 WO_TEST_DOES_NOT_THROW([mock stringWithString:@"foo"]);
56 // should throw for instance methods
57 WO_TEST_THROWS([[mock accept] lowercaseString]);
59 // should throw for unknown methods
60 WO_TEST_THROWS(objc_msgSend([mock accept], @selector(foobar)));