public void ConfirmNavigationRequest_WhenCallBackIsTrue_NoDialogIsDisplayed() { // arrange var dialogService = new Mock <IDialogService>(); dialogService.Setup(x => x.ConfirmDialog(It.IsAny <String>(), It.IsAny <String>())).Returns(DialogResult.No); var sut = new XamlMVVMDemoCodeViewModel(_businessServiceMock, dialogService.Object); sut.OnNavigatedTo(_navigationContext); var test = false; // act sut.ConfirmNavigationRequest(It.IsAny <Prism.Regions.NavigationContext>(), confirm => test = confirm); // assert Assert.True(test); dialogService.Verify(x => x.ConfirmDialog(It.IsAny <String>(), It.IsAny <String>()), Times.Never()); }
public void ProductThatIsDirty_ConfirmNavigationRequest_CallBackIsFalseWhenDialogResultIsCancel() { // arrange var dialogService = new Mock <IDialogService>(); dialogService.Setup(x => x.ConfirmDialog(It.IsAny <String>(), It.IsAny <String>())).Returns(DialogResult.Cancel); var sut = new XamlMVVMDemoCodeViewModel(_businessServiceMock, dialogService.Object); sut.OnNavigatedTo(_navigationContext); sut.Product = new Product { IsDirty = true }; var test = false; // act sut.ConfirmNavigationRequest(It.IsAny <Prism.Regions.NavigationContext>(), confirm => test = confirm); // assert Assert.False(test); dialogService.Verify(x => x.ConfirmDialog(It.IsAny <String>(), It.IsAny <String>()), Times.Once); }