<NME> TemplateTests.swift
<BEF> //
//  TemplateTests.swift
//  TemplateKit
//
//  Created by Matias Cudich on 10/26/16.
//  Copyright © 2016 Matias Cudich. All rights reserved.
//

import XCTest
import TemplateKit
import CSSParser

class TemplateTests: XCTestCase {
class TemplateTests: XCTestCase {
  func testParseTemplate() {
    let template = Bundle(for: TemplateTests.self).url(forResource: "SimpleTemplate", withExtension: "xml")!
    let parsed = try! Template(xml: Data(contentsOf: template))
    let element = try! parsed.makeElement(with: FakeModel()) as! ElementData<DefaultProperties>
    XCTAssertEqual(UIColor.red, element.properties.core.style.backgroundColor)
  }
  func testApplyStylesheet() {
    let grandchild = text(TextProperties())
    let child = box(DefaultProperties(["classNames": "child"]), [grandchild])
    let parent = box(DefaultProperties(["id": "parent"]), [child])

    let stylesheet = StyleSheet(string: "#parent { fontSize: 20 } .child { width: 50 }", inheritedProperties: ["fontSize"])!
    let template = Template(parent, stylesheet)
    let built = template.build(with: FakeModel()) as! ElementData<DefaultProperties>
    let builtChild = built.children?.first as! ElementData<DefaultProperties>
    let builtGrandchild = child.children?.first as! ElementData<TextProperties>

    XCTAssertEqual(20, built.properties.textStyle.fontSize)
    XCTAssertEqual(20, builtChild.properties.textStyle.fontSize)
    XCTAssertEqual(20, builtGrandchild.properties.textStyle.fontSize)

    XCTAssertEqual(50, builtChild.properties.core.layout.width)
  }
}

<MSG> Added support for remote style sheets, and made Template more generic

<DFF> @@ -14,7 +14,9 @@ struct FakeModel: Model {}
 class TemplateTests: XCTestCase {
   func testParseTemplate() {
     let template = Bundle(for: TemplateTests.self).url(forResource: "SimpleTemplate", withExtension: "xml")!
-    let parsed = try! Template(xml: Data(contentsOf: template))
+    let xmlTemplate = try! XMLDocumentParser(data: Data(contentsOf: template)).parse()
+    let styleSheet = StyleSheet(string: xmlTemplate.styleElements.first!.value!)
+    let parsed = Template(elementProvider: xmlTemplate.componentElement!, styleSheet: styleSheet)
     let element = try! parsed.makeElement(with: FakeModel()) as! ElementData<DefaultProperties>
     XCTAssertEqual(UIColor.red, element.properties.core.style.backgroundColor)
   }

Added support for remote style sheets, and made Template more generic