forked from Brightify/Cuckoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCuckooFunctionsTest.swift
More file actions
67 lines (53 loc) · 1.84 KB
/
Copy pathCuckooFunctionsTest.swift
File metadata and controls
67 lines (53 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// CuckooFunctionsTest.swift
// Cuckoo
//
// Created by Filip Dolnik on 04.07.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import XCTest
@testable import Cuckoo
class CuckooFunctionsTest: XCTestCase {
func testReset() {
let mock = MockTestedClass().withEnabledSuperclassSpy()
stub(mock) { mock in
when(mock.count(characters: anyString())).thenReturn(10)
}
XCTAssertEqual(mock.count(characters: "a"), 10)
reset(mock)
verify(mock, never()).count(characters: "a")
XCTAssertEqual(mock.count(characters: "a"), 1)
verify(mock).count(characters: "a")
}
func testClearStubs() {
let mock = MockTestedClass().withEnabledSuperclassSpy()
stub(mock) { mock in
when(mock.count(characters: anyString())).thenReturn(10)
}
XCTAssertEqual(mock.count(characters: "a"), 10)
clearStubs(mock)
verify(mock).count(characters: "a")
XCTAssertEqual(mock.count(characters: "a"), 1)
verify(mock, times(2)).count(characters: "a")
}
func testClearInvocations() {
let mock = MockTestedClass()
stub(mock) { mock in
when(mock.count(characters: anyString())).thenReturn(10)
}
XCTAssertEqual(mock.count(characters: "a"), 10)
clearInvocations(mock)
verify(mock, never()).count(characters: "a")
XCTAssertEqual(mock.count(characters: "a"), 10)
verify(mock).count(characters: "a")
}
func testVerifyNoMoreInteractions() {
let mock = MockTestedClass()
stub(mock) { mock in
when(mock.noReturn()).thenDoNothing()
}
mock.noReturn()
verify(mock).noReturn()
verifyNoMoreInteractions(mock)
}
}