I want to provide a null
value for all calls with an id >= 100 -- and a concrete Product
instance with the captured id for all others:
every { repoMock.findById(more(100, true)) } returns null
every { repoMock.findById(capture(idSlot)) } answers { Product(idSlot.captured, "Sample Product", 1.99) }
However the first behaviour is ignored -- for id 1234 the mock returns a Product instance.
I know I can fix it by having an answers{..}
block with an if
-- but what's going on here? Is the capturing behaviour ruling out all other behaviours?