I'm trying to fake a sealed external audio source using FakeItEasy.
I've wrapped the audio source and successfully faked the wrapper, so I know the basics are right. Here's the bit I'm currently stuck on:
The audio source returns isPlaying = true after it's been called with Play(). isPlaying will remain true until the audio clip has finished playing at which point it'll return to false.
I can fake the first part of this with the following code:
A.CallTo(() => fakeAudioSourceWrapper.Play())
.Invokes(() => fakeAudioSourceWrapper.isPlaying = true)
Which successfully fakes isPlaying being true after the Play function is called. What I'd like to do is then delay a certain time and then make it return false to simulate what happens after the clip has finished playing.
I tried
A.CallTo(() => fakeAudioSourceWrapper.Play())
.Invokes(() => fakeAudioSourceWrapper.isPlaying = true)
.Then
.Invokes(() => fakeAudioSourceWrapper.isPlaying = false);
with the idea that a call to isPlaying would return true the first time it was called after Play() was called, and return false the second time, but got no joy.
Is there a way to do this?