Slide 12
Slide 12 text
let sut = MessageSender(messageType: .image)
let cases: [(line: UInt, text: String?, image: UIImage?, expects: Bool)] = [
(line: #line, text: nil, image: UIImage(), expects: true),
// text͕͋Δ߹ɺ80จࣈҎͰͳ͍ͱinvalid
(line: #line, text: String(repeating: "x", count: 80), image: UIImage(), expects: true),
(line: #line, text: String(repeating: "x", count: 81), image: UIImage(), expects: false),
// image͕ͳ͚Ε͍͔ͳΔ߹invalid
(line: #line, text: nil, image: UIImage(), expects: false),
(line: #line, text: String(repeating: "x", count: 80), image: UIImage(), expects: false),
(line: #line, text: String(repeating: "x", count: 81), image: UIImage(), expects: false),
]
cases.forEach {
sut.text = $0.text
sut.image = $0.image
XCTAssertEqual(sut.isValid, $0.expects, line: $0.line)
}
12