class Given { var sut: T init(_ sut: T) { self.sut = sut } func the(_ keyPath: WritableKeyPath, is u: U) -> Given { sut[keyPath: keyPath] = u return self } func apply(_ c: (T) -> Void) -> Given { c(sut) return self } func map(_ c: (T) -> U) -> Given { return Given(c(sut)) } var expect: Expectation { return Expectation(sut: sut) } } struct Expectation { let sut: T @discardableResult func the(_ keyPath: KeyPath, toBe value: U) -> Expectation { XCTAssertEqual(sut[keyPath: keyPath], value) return self } @discardableResult func the(_ keyPath: KeyPath, toBeGreaterThan value: U) -> Expectation { XCTAssertGreaterThan(sut[keyPath: keyPath], value) return self } @discardableResult func the(_ keyPath: KeyPath, toBeLessThan value: U) -> Expectation { XCTAssertLessThan(sut[keyPath: keyPath], value) return self } @discardableResult func the(_ keyPath: KeyPath, toNotBe value: U) -> Expectation { XCTAssertNotEqual(sut[keyPath: keyPath], value) return self } @discardableResult func nilValueFor(_ keyPath: KeyPath) -> Expectation { XCTAssertNil(sut[keyPath: keyPath]) return self } @discardableResult func nonNilValueFor(_ keyPath: KeyPath) -> Expectation { XCTAssertNotNil(sut[keyPath: keyPath]) return self } }