Enumeration
StubbingManager.TransitionStrategy
public enum TransitionStrategy
When to use the next chained implementation provider.
Relationships
Member Of
StubbingManager
An intermediate object used for stubbing declarations returned by
given
.
Enumeration Cases
after
case after(_ times: Int)
Go to the next provider after providing a certain number of implementations.
This transition strategy is particularly useful for non-finite value providers such as
sequence
and loopingSequence
.
given(bird.name)
.willReturn(loopingSequence(of: "Ryan", "Sterling"), transition: .after(3))
.willReturn("Andrew")
print(bird.name) // Prints "Ryan"
print(bird.name) // Prints "Sterling"
print(bird.name) // Prints "Ryan"
print(bird.name) // Prints "Andrew"
onFirstNil
case onFirstNil
Use the current provider until it provides a nil
implementation.
This transition strategy should be used for finite value providers like finiteSequence
that are nil
terminated to indicate an invalidated state.
given(bird.name)
.willReturn(finiteSequence(of: "Ryan", "Sterling"), transition: .onFirstNil)
.willReturn("Andrew")
print(bird.name) // Prints "Ryan"
print(bird.name) // Prints "Sterling"
print(bird.name) // Prints "Andrew"