public void GivenAlreadyRegisteredView_WhenClosingWithCancel_ThenItReturnsProper() { _dialogServiceSubject = ProvideDialogService(); _dialogServiceSubject.Register <DialogViewModelFixture, DialogViewFixture>(); DialogViewModelFixture vmFixture = new DialogViewModelFixture(); bool?dialogResult = null; _dialogServiceSubject.Instantiate(vmFixture); Task showTask = Task.Run(() => dialogResult = _dialogServiceSubject.ShowDialog(vmFixture)); vmFixture.RequestCloseWithCancel(); showTask.Wait(); Assert.False(dialogResult); }
public void GivenAlreadyRegisteredView_WhenClosingWithX_ThenItClosesWindow() { _dialogServiceSubject = ProvideDialogService(); _dialogServiceSubject.Register <DialogViewModelFixture, DialogViewFixture>(); DialogViewModelFixture vmFixture = new DialogViewModelFixture(); bool?dialogResult = null; _dialogServiceSubject.Instantiate(vmFixture); Task showTask = Task.Run(() => dialogResult = _dialogServiceSubject.ShowDialog(vmFixture)); Assert.Throws <DialogClosedException>(() => { vmFixture.RequestCloseWithX(); showTask.Wait(); }); }
public void GivenAlreadyRegisteredViewModel_WhenInstantiateNewOne_ItRemovesOldOne() { _dialogServiceSubject = ProvideDialogService(); _dialogServiceSubject.Register <DialogViewModelFixture, DialogViewWithDataContextFixture>(); DialogViewModelFixture vmFixture = new DialogViewModelFixture(); DialogViewModelFixture vmFixture2 = new DialogViewModelFixture(); _dialogServiceSubject.Instantiate(vmFixture); _dialogServiceSubject.Instantiate(vmFixture2); try { _dialogServiceSubject.ShowDialog(vmFixture2); } catch (ErrorOrMessageDialogShownException e) { Assert.Equal(vmFixture2.GetHashCode(), e.DataContext.GetHashCode()); Assert.NotEqual(vmFixture.GetHashCode(), e.DataContext.GetHashCode()); } }