File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -62,3 +62,37 @@ let value = cache.retrieve(at: .myKey)
6262``` swift
6363cache.remove (at : .myKey )
6464```
65+
66+ ### Usage in tests
67+
68+ This library provides some helpers for easy usage on tests such as:
69+
70+ #### Noop
71+
72+ An implementation of ` Cache ` that does nothing when called.
73+
74+ ``` swift
75+ let cache = Cache.noop
76+ ```
77+
78+
79+ #### Failing
80+
81+ An implementation of ` Cache ` that fails with an ` XCTFail ` call.
82+
83+ ``` swift
84+ var setEntryCalled = false
85+
86+ let cache = Cache.failing
87+ .override (
88+ setEntry : { entry, key in
89+ setEntryCalled = true
90+ }
91+ )
92+
93+ cache.set (" string value" , at : .myKey )
94+
95+ XCTAssertTrue (setEntryCalled)
96+ ```
97+
98+ At the code snipped above all calls to a method that wasn't overriden will terminate with a ` XCTFail ` .
You can’t perform that action at this time.
0 commit comments