1
1
//
2
- // MethodNotificationCenterTests .swift
2
+ // MethodNotificationCenterSwiftTests .swift
3
3
// MethodNotificationCenterTests
4
4
//
5
5
// Copyright © 2021 SomeRandomiOSDev. All rights reserved.
8
8
import MethodNotificationCenter
9
9
import XCTest
10
10
11
- // MARK: - MethodNotificationCenterTests Definition
11
+ // MARK: - MethodNotificationCenterSwiftTests Definition
12
12
13
- class MethodNotificationCenterTests : XCTestCase {
13
+ class MethodNotificationCenterSwiftTests : XCTestCase {
14
14
15
15
// MARK: Test Methods
16
16
17
- func testRecivingNotifications1 ( ) {
17
+ func testReceivingNotifications1 ( ) {
18
18
let test = TestClass1 ( )
19
19
let observer = MethodNotificationCenter . addObserver ( for: #selector( TestClass1 . increment) , object: test) { notification in
20
20
XCTAssertEqual ( test. value, ( notification. isPriorToMethodCall ? 0 : 2 ) )
@@ -23,13 +23,13 @@ class MethodNotificationCenterTests: XCTestCase {
23
23
24
24
XCTAssertEqual ( test. value, 0 )
25
25
test. perform ( #selector( TestClass1 . increment) )
26
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
26
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
27
27
XCTAssertEqual ( test. value, 3 )
28
28
29
29
MethodNotificationCenter . removeObserver ( observer)
30
30
}
31
31
32
- func testRecivingNotifications2 ( ) {
32
+ func testReceivingNotifications2 ( ) {
33
33
let test = TestClass2 ( )
34
34
let observer = MethodNotificationCenter . addObserver ( for: #selector( TestClass1 . increment) , object: test) { notification in
35
35
XCTAssertEqual ( test. value, ( notification. isPriorToMethodCall ? 0 : 2 ) )
@@ -38,13 +38,13 @@ class MethodNotificationCenterTests: XCTestCase {
38
38
39
39
XCTAssertEqual ( test. value, 0 )
40
40
test. perform ( #selector( TestClass1 . increment) )
41
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
41
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
42
42
XCTAssertEqual ( test. value, 3 )
43
43
44
44
MethodNotificationCenter . removeObserver ( observer)
45
45
}
46
46
47
- func testRecivingNotifications3 ( ) {
47
+ func testReceivingNotifications3 ( ) {
48
48
let test = TestClass3 ( )
49
49
let observer = MethodNotificationCenter . addObserver ( for: #selector( TestClass1 . increment) , object: test) { notification in
50
50
XCTAssertEqual ( test. value, ( notification. isPriorToMethodCall ? 0 : 2 ) )
@@ -53,7 +53,7 @@ class MethodNotificationCenterTests: XCTestCase {
53
53
54
54
XCTAssertEqual ( test. value, 0 )
55
55
test. perform ( #selector( TestClass1 . increment) )
56
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
56
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
57
57
XCTAssertEqual ( test. value, 3 )
58
58
59
59
MethodNotificationCenter . removeObserver ( observer)
@@ -76,8 +76,8 @@ class MethodNotificationCenterTests: XCTestCase {
76
76
XCTAssertEqual ( test2. value, 0 )
77
77
test. perform ( #selector( TestClass1 . increment) )
78
78
test2. perform ( #selector( TestClass1 . increment) )
79
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
80
- //test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
79
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
80
+ // test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
81
81
XCTAssertEqual ( test. value, 3 )
82
82
XCTAssertEqual ( test2. value, 3 )
83
83
@@ -99,18 +99,18 @@ class MethodNotificationCenterTests: XCTestCase {
99
99
100
100
XCTAssertEqual ( test. value, 0 )
101
101
test. perform ( #selector( TestClass1 . increment) )
102
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
102
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
103
103
XCTAssertEqual ( test. value, 3 )
104
104
test. perform ( #selector( TestClass1 . incrementBy2) )
105
- //test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
105
+ // test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
106
106
XCTAssertEqual ( test. value, 7 )
107
107
MethodNotificationCenter . removeObserver ( observer2)
108
108
test. perform ( #selector( TestClass1 . incrementBy2) )
109
- //test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
109
+ // test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
110
110
XCTAssertEqual ( test. value, 9 )
111
111
MethodNotificationCenter . removeObserver ( observer)
112
112
test. perform ( #selector( TestClass1 . increment) )
113
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
113
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
114
114
XCTAssertEqual ( test. value, 10 )
115
115
}
116
116
@@ -139,30 +139,30 @@ class MethodNotificationCenterTests: XCTestCase {
139
139
XCTAssertEqual ( test2. value, 0 )
140
140
test. perform ( #selector( TestClass1 . increment) )
141
141
test2. perform ( #selector( TestClass1 . increment) )
142
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
143
- //test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
142
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
143
+ // test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
144
144
XCTAssertEqual ( test. value, 3 )
145
145
XCTAssertEqual ( test2. value, 3 )
146
146
test. perform ( #selector( TestClass1 . incrementBy2) )
147
147
test2. perform ( #selector( TestClass1 . incrementBy2) )
148
- //test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
149
- //test2.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
148
+ // test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
149
+ // test2.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
150
150
XCTAssertEqual ( test. value, 7 )
151
151
XCTAssertEqual ( test2. value, 7 )
152
152
MethodNotificationCenter . removeObserver ( observer2)
153
153
MethodNotificationCenter . removeObserver ( observer4)
154
154
test. perform ( #selector( TestClass1 . incrementBy2) )
155
155
test2. perform ( #selector( TestClass1 . incrementBy2) )
156
- //test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
157
- //test2.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
156
+ // test.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
157
+ // test2.incrementBy2() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
158
158
XCTAssertEqual ( test. value, 9 )
159
159
XCTAssertEqual ( test2. value, 9 )
160
160
MethodNotificationCenter . removeObserver ( observer)
161
161
MethodNotificationCenter . removeObserver ( observer3)
162
162
test. perform ( #selector( TestClass1 . increment) )
163
163
test2. perform ( #selector( TestClass1 . increment) )
164
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
165
- //test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
164
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
165
+ // test2.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
166
166
XCTAssertEqual ( test. value, 10 )
167
167
XCTAssertEqual ( test2. value, 10 )
168
168
}
@@ -189,7 +189,7 @@ class MethodNotificationCenterTests: XCTestCase {
189
189
190
190
XCTAssertEqual ( test. value, 0 )
191
191
test. perform ( #selector( TestClass1 . noop) )
192
- //test.noop() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
192
+ // test.noop() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
193
193
XCTAssertEqual ( test. value, 8 )
194
194
195
195
MethodNotificationCenter . removeObserver ( observer)
@@ -208,11 +208,11 @@ class MethodNotificationCenterTests: XCTestCase {
208
208
209
209
XCTAssertEqual ( test. value, 0 )
210
210
test. perform ( #selector( TestClass1 . increment) )
211
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
211
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
212
212
XCTAssertEqual ( test. value, 3 )
213
213
unmanagedObserver. release ( ) // causes observer to be overreleased, but that's okay for our unit testing
214
214
test. perform ( #selector( TestClass1 . increment) )
215
- //test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
215
+ // test.increment() // Can't call directly in Swift as the complier will skip the ObjC runtime and call the Swift function directly
216
216
XCTAssertEqual ( test. value, 4 )
217
217
}
218
218
}
0 commit comments