Initial project with Context and Variable.

This commit is contained in:
Kyle Fuller
2014-10-23 14:59:57 +01:00
parent c415bfe84b
commit e34084f3f0
10 changed files with 795 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
//
// ContextTests.swift
// Stencil
//
// Created by Kyle Fuller on 23/10/2014.
// Copyright (c) 2014 Cocode. All rights reserved.
//
import Cocoa
import XCTest
import Stencil
class ContextTests: XCTestCase {
var context:Context!
override func setUp() {
context = Context(dictionary: ["name": "Kyle"])
}
func testItAllowsYouToRetrieveAValue() {
let name = context["name"] as String!
XCTAssertEqual(name, "Kyle")
}
func testItAllowsYouToSetValue() {
context["name"] = "Katie"
let name = context["name"] as String!
XCTAssertEqual(name, "Katie")
}
func testItAllowsYouToRemoveAValue() {
context["name"] = nil
XCTAssertNil(context["name"])
}
func testItAllowsYouToRetrieveAValueFromParent() {
context.push()
let name = context["name"] as String!
XCTAssertEqual(name, "Kyle")
}
func testItAllowsYouToOverideAParentVariable() {
context.push()
context["name"] = "Katie"
let name = context["name"] as String!
XCTAssertEqual(name, "Katie")
}
func testShowAllowYouToPopVariablesRestoringPreviousState() {
context.push()
context["name"] = "Katie"
context.pop()
let name = context["name"] as String!
XCTAssertEqual(name, "Kyle")
}
func testItAllowsYouToPushADictionaryToTheStack() {
context.push(["name": "Katie"])
let name = context["name"] as String!
XCTAssertEqual(name, "Katie")
}
func testItAllowsYouToCompareTwoContextsForEquality() {
let otherContext = Context(dictionary: ["name": "Kyle"])
XCTAssertEqual(otherContext, context )
}
}