chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Please make the second .WillReturn() on a property overwrite the first .WillReturn() on that property.

In this screenshot the proposed way is easy to read but in the current way the reader needs to know how second calls to .WillReturn() work in Isolator so the current way is harder to read.

[ img ]
asked by Neil (27.7k points)

2 Answers

0 votes
Hi Neil,

This is actually by design (even though designs can change :)). When repeating WhenCalled() statements, call behavior sequencing kicks in, which means Isolator will return the behaviors by order, with the default value being the last specified behavior. This behavior starts when you specify the second WhenCalled() statement, which is why you still get the first WhenCalled() return value right after it - you are getting the first sequenced behavior.

On a wider perspective, it is generally not advised to mix Arrange and Act code - it makes for less readable tests and often means the Act stage can be broken up into two tests.

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Thanks Doron.
answered by Neil (27.7k points)
...