     }
 }
 
-func createResolver(providing containers: MockContainer...) -> PubgrubDependencyResolver<MockProvider> {
-    let provider = MockProvider(containers: containers)
-    return PubgrubDependencyResolver(provider, delegate)
-}
+class DependencyGraphBuilder {
+    private var containers: [String: MockContainer] = [:]
+    private var references: [String: PackageReference] = [:]
+
+    private func reference(for packageName: String) -> PackageReference {
+        if let reference = self.references[packageName] {
+            return reference
+        }
+        let newReference = PackageReference(identity: packageName, path: "")
+        self.references[packageName] = newReference
+        return newReference
+    }
+
+    func serve(root: String, with dependencies: [String: VersionSetSpecifier]) {
+        let rootDependencies = dependencies.map {
+            (package: reference(for: $0), requirement: $1)
+        }
+
+        let rootContainer = MockContainer(name: reference(for: root),
+                                          unversionedDependencies: rootDependencies)
+        self.containers[root] = rootContainer
+    }
+
+    func serve(_ package: String, at version: Version, with dependencies: [String: VersionSetSpecifier] = [:]) {
+        let packageReference = reference(for: package)
+        let container = self.containers[package] ?? MockContainer(name: packageReference)
+        container._versions.append(version)
+        container._versions = container._versions.sorted().reversed()
+
+        let packageDependencies = dependencies.map {
+            (container: reference(for: $0), requirement: PackageRequirement.versionSet($1))
+        }
+        container.dependencies[version.description] = packageDependencies
+        self.containers[package] = container
+    }
+
+    func create() -> PubgrubDependencyResolver<MockProvider> {
+        defer {
+            self.containers = [:]
+            self.references = [:]
+        }
+        let provider = MockProvider(containers: self.containers.values.map { $0 })
+        return PubgrubDependencyResolver(provider, delegate)
+    }
+}
+
+let builder = DependencyGraphBuilder()
 
 
 public class _MockResolverDelegate: DependencyResolverDelegate {
-    public typealias Identifier = MockContainer.Identifier
+    public typealias Identifier = PackageReference
 
     public init() {}
 

        self.init(name: name, dependencies: dependencies)
    }

    private init(
        name: Identifier,
        dependencies: [String: [Dependency]] = [:]
        ) {
        self.name = name

    }

    func testResolutionAvoidingConflictResolutionDuringDecisionMaking() {
        builder.serve(root: "root", with: ["a": v1Range, "b": v1Range])
        builder.serve("a", at: v1)
        builder.serve("a", at: v1_1, with: ["b": v2Range])
        builder.serve("b", at: v1)
        builder.serve("b", at: v1_1)
        builder.serve("b", at: v2)

        let resolver = builder.create()
        let result = resolver.solve(root: rootRef, pins: [])

        switch result {
