I am trying to write a unit test that tests my ReactiveUI ViewModel. In my ViewModel I want to retrieve comments from my database. You can also filter these comments by text and by creator.
For filtering I use the command this.WhenAnyValue like here:
Observable.Merge(
this.WhenAnyValue(vm => vm.CommentCreatorId)
.Select(s => Unit.Default)
.Throttle(TimeSpan.FromMilliseconds(300)),
this.WhenAnyValue(vm => vm.SearchText)
.Select(s => Unit.Default)
.Throttle(TimeSpan.FromMilliseconds(700))
)
.InvokeCommand(this, x => x.GetComments);
So I have a subscription for CommentCreatorID and SearchText that calls GetComments when it is changed.
This works perfectly, but now I want to test it!
Is there any way to identify the Invoke from a specific subscription? I ask this because it could be that in the background other things are executing certain commands that call the GetComments. I need to identify in my unit test that the Invoke is coming from my modified SearchText.