How to Mock DialogService?


I am trying to write Bunit test by mocking the DialogService Confirm event that returns true but it is not possible to override the event because it is not overridable. Is there a way to work with it?

what i thought i would do something like this

_dialogservice.Setup(x => x.Confirm("", "", null)).ReturnsAsync(true);

At the moment the confirm method is not virtual and cannot be overridden.

Any updates on this? There seems to be no way to unit test code that uses the Alert or Confirm dialogs?

Hi @eric1.

There isn't any update on this however we would accept a pull request which makes this methods virtual.

Not sure if I did this correctly, but I created a fork, and then created a branch off the fork and created a PR with the change. Please let me know if there is anything else I need to do.