Skip to content

Commit 730a02b

Browse files
author
Michael Long
committed
Updates for 12.5
1 parent a8e962a commit 730a02b

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Fix threading issue in LazyInjected and WeakLazyInjected property wrappers
66
* Fix argument passing in .implements
7+
* Update projct for Xcode 12.5
8+
* Update Swift class deprecation
79

810
### 1.4.1
911

Tests/ResolverTests/ResolverScopeReferenceTests.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,49 @@ class ResolverScopeReferenceTests: XCTestCase {
9999
}
100100
}
101101

102+
func testResolverScopeCachedImplements() {
103+
// Reset...
104+
ResolverScope.cached.reset()
105+
resolver.register { XYZSessionService() }
106+
.implements(XYZSessionProtocol.self)
107+
.scope(.cached)
108+
let service1: XYZSessionService? = resolver.optional()
109+
let service2: XYZSessionService? = resolver.optional()
110+
XCTAssertNotNil(service1)
111+
XCTAssertNotNil(service2)
112+
// Also test if "implements" protocol resolves
113+
let service3: XYZSessionProtocol? = resolver.optional()
114+
XCTAssertNotNil(service3)
115+
// check identity
116+
var originalID: UUID?
117+
if let s1 = service1, let s2 = service2, let s3 = service3 {
118+
XCTAssert(s1.id == s2.id)
119+
XCTAssert(s2.id == s3.id)
120+
originalID = s1.id
121+
} else {
122+
XCTFail("sessions not cached")
123+
}
124+
// Reset...
125+
ResolverScope.cached.reset()
126+
// ...and try again
127+
var newUUID: UUID?
128+
if let newService: XYZSessionService = resolver.optional(), let originalID = originalID {
129+
XCTAssert(originalID != newService.id)
130+
newUUID = newService.id
131+
} else {
132+
XCTFail("newService not resolved")
133+
}
134+
// Reset...
135+
ResolverScope.cached.reset()
136+
// ...and try once more with protocol
137+
if let newService: XYZSessionProtocol = resolver.optional(), let originalID = originalID, let newID = newUUID {
138+
XCTAssert(originalID != newService.id)
139+
XCTAssert(newID != newService.id)
140+
} else {
141+
XCTFail("newService not resolved")
142+
}
143+
}
144+
102145
func testResolverScopeUnique() {
103146
resolver.register { XYZSessionService() }.scope(.unique)
104147
let service1: XYZSessionService? = resolver.optional()

Tests/ResolverTests/XCTestManifests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ extension ResolverArgumentTests {
66
// `swift test --generate-linuxmain`
77
// to regenerate.
88
static let __allTests__ResolverArgumentTests = [
9+
("testGetKeyedArgumentPassingInImplements", testGetKeyedArgumentPassingInImplements),
910
("testGetKeyedArguments", testGetKeyedArguments),
1011
("testGetPropertiesKeyedArguments", testGetPropertiesKeyedArguments),
1112
("testGetSingleArgument", testGetSingleArgument),
13+
("testGetSingleArgumentPassingInImplements", testGetSingleArgumentPassingInImplements),
1214
("testKeyedArgumentsFunction", testKeyedArgumentsFunction),
1315
("testOptionalArgument", testOptionalArgument),
1416
("testPropertiesGetSingleArgument", testPropertiesGetSingleArgument),
@@ -150,6 +152,7 @@ extension ResolverScopeReferenceTests {
150152
static let __allTests__ResolverScopeReferenceTests = [
151153
("testResolverScopeApplication", testResolverScopeApplication),
152154
("testResolverScopeCached", testResolverScopeCached),
155+
("testResolverScopeCachedImplements", testResolverScopeCachedImplements),
153156
("testResolverScopeGraph", testResolverScopeGraph),
154157
("testResolverScopeShared", testResolverScopeShared),
155158
("testResolverScopeUnique", testResolverScopeUnique),

0 commit comments

Comments
 (0)