Skip to content

Commit

Permalink
Fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
philippzagar committed Dec 6, 2023
1 parent a7697b9 commit c89322e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Tests/SpeziTests/DependenciesTests/DependencyBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTRuntimeAssertions

private protocol ExampleTypeConstraint: Module {}

private final class ExampleDependencyModule: ExampleTypeConstraint {}
private final class ExampleDependentModule: ExampleTypeConstraint {}

@resultBuilder
private enum ExampleDependencyBuilder: DependencyCollectionBuilder {
Expand All @@ -21,7 +21,7 @@ private enum ExampleDependencyBuilder: DependencyCollectionBuilder {
}
}

class ExampleModule: Module {
class ExampleDependencyModule: Module {
@Dependency var dependencies: [any Module]


Expand All @@ -32,16 +32,15 @@ class ExampleModule: Module {
}
}

enum ExampleConfiguration {
static let exampleModule = ExampleModule {
ExampleDependencyModule()
}
}


final class DependencyBuilderTests: XCTestCase {
func testDependencyBuilder() throws {
XCTAssertEqual(ExampleConfiguration.exampleModule.dependencies.count, 1)
_ = try XCTUnwrap(ExampleConfiguration.exampleModule.dependencies[0] as? ExampleDependencyModule)
let module = ExampleDependencyModule {
ExampleDependentModule()
}
let sortedModules = DependencyManager.resolve([module])
XCTAssertEqual(sortedModules.count, 2)
_ = try XCTUnwrap(sortedModules[0] as? ExampleDependentModule)
_ = try XCTUnwrap(sortedModules[1] as? ExampleDependencyModule)
}
}

0 comments on commit c89322e

Please sign in to comment.