/
MethodArgumentInfoTests.m
98 lines (79 loc) · 2.56 KB
/
MethodArgumentInfoTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// MethodArgumentInfoTests.m
// appledoc
//
// Created by Tomaž Kragelj on 4/17/12.
// Copyright (c) 2012 Tomaz Kragelj. All rights reserved.
//
#import "Store.h"
#import "TestCaseBase.h"
@interface MethodArgumentInfoTests : TestCaseBase
@end
@interface MethodArgumentInfoTests (CreationMethods)
- (void)runWithMethodArgumentInfo:(void(^)(MethodArgumentInfo *info))handler;
@end
@implementation MethodArgumentInfoTests
#pragma mark - Verify lazy initialization
- (void)testLazyInitializersWork {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// execute & verify
assertThat(info.argumentType, instanceOf([TypeInfo class]));
}];
}
#pragma mark - beginMethodArgumentTypes
- (void)testBeginMethodArgumentTypesShouldCreateNewMethodArgument {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// setup
id mock = [OCMockObject mockForClass:[Store class]];
[[mock expect] pushRegistrationObject:OCMOCK_ANY];
info.objectRegistrar = mock;
// execute
[info beginMethodArgumentTypes];
// verify
STAssertNoThrow([mock verify], nil);
}];
}
#pragma mark - appendMethodArgumentSelector:
- (void)testAppendMethodArgumentSelectorShouldAssignGivenString {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// execute
[info appendMethodArgumentSelector:@"value"];
// verify
assertThat(info.argumentSelector, equalTo(@"value"));
}];
}
- (void)testAppendMethodArgumentSelectorShouldUseLastValueIfSentMultipleTimes {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// execute
[info appendMethodArgumentSelector:@"value1"];
[info appendMethodArgumentSelector:@"value2"];
// verify
assertThat(info.argumentSelector, equalTo(@"value2"));
}];
}
#pragma mark - appendMethodArgumentVariable:
- (void)testAppendMethodArgumentVariableShouldAssignGivenString {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// execute
[info appendMethodArgumentVariable:@"value"];
// verify
assertThat(info.argumentVariable, equalTo(@"value"));
}];
}
- (void)testAppendMethodArgumentVariableShouldUseLastValueIfSentMultipleTimes {
[self runWithMethodArgumentInfo:^(MethodArgumentInfo *info) {
// execute
[info appendMethodArgumentVariable:@"value1"];
[info appendMethodArgumentVariable:@"value2"];
// verify
assertThat(info.argumentVariable, equalTo(@"value2"));
}];
}
@end
#pragma mark -
@implementation MethodArgumentInfoTests (CreationMethods)
- (void)runWithMethodArgumentInfo:(void(^)(MethodArgumentInfo *info))handler {
MethodArgumentInfo *info = [MethodArgumentInfo new];
handler(info);
}
@end