 
   return suites
 }
-

  let supportedExpansionLevel = 3
  let supportedExtractionLevel = 2

  func testExpansion() {
    for suite in suites(supportedExpansionLevel) {
      for testcase in suite.cases {
        let expanded = testcase.uriTemplate.expand(suite.variables)
        XCTAssertTrue(contains(testcase.expected, expanded), "\(testcase.template). \(testcase.expected[0]) !~ \(expanded)")
      }
    }
  }

  func testExtraction() {
    for suite in suites(supportedExtractionLevel) {
      for testcase in suite.cases {
        let template = testcase.uriTemplate

        for uri in testcase.expected {
          let variables = template.extract(uri)
          var expectedVariables = Dictionary<String, String>()
          for variable in template.variables {
            if let value:AnyObject = variables[variable] as AnyObject? {
              expectedVariables[variable] = "\(value)"
            } else {
              XCTAssert(false, "Missing Variable \(variable)")
            }
          }

          XCTAssertEqual(variables as NSDictionary, expectedVariables as NSDictionary, "\(template)")
        }
      }
    }
  }

  // MARK:

  func suites(level:Int) -> [Suite] {
    let bundle = NSBundle(forClass:object_getClass(self))
    let urls = files.map { file -> NSURL in
      bundle.URLForResource(file, withExtension: "json")!
    }

    return loadSuites(urls).filter { suite in
      level >= suite.level
    }
  }
}


import XCTest
import URITemplate

// MARK: Tests

func testExpansion(suite:Suite, testcase:Case) {
  let expanded = testcase.uriTemplate.expand(suite.variables)
  XCTAssertTrue(contains(testcase.expected, expanded), "\(testcase.template). \(testcase.expected[0]) !~ \(expanded)")
}

func testExtraction(suite:Suite, testcase:Case) {
  let template = testcase.uriTemplate

  for uri in testcase.expected {
    let variables = template.extract(uri)
    var expectedVariables = Dictionary<String, String>()
    for variable in template.variables {
      if let value:AnyObject = variables[variable] as AnyObject? {
        expectedVariables[variable] = "\(value)"
      } else {
        XCTAssert(false, "Missing Variable \(variable)")
      }
    }

    XCTAssertEqual(variables as NSDictionary, expectedVariables as NSDictionary, "\(template)")
  }
}

@objc class URITemplateCasesTests : XCTestCase {
  let files = [
    "extended-tests",
//    "negative-tests",
