示例#1
0
        public void WhenClosingDialogWithMultipleDialogHostsItThrowsTooManyMatchingInstances()
        {
            var secondInstance = new DialogHost();

            try
            {
                secondInstance.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
                var ex = Assert.Throws <InvalidOperationException>(() => DialogHost.Close(null));
                Assert.Equal("Multiple viable DialogHosts. Specify a unique Identifier on each DialogHost, especially where multiple Windows are a concern.", ex.Message);
            }
            finally
            {
                secondInstance.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));
            }
        }
        public async Task WhenMultipleDialogHostsHaveTheSameIdentifierItThrows()
        {
            var id = Guid.NewGuid();

            _dialogHost.Identifier = id;
            var otherDialogHost = new DialogHost {
                Identifier = id
            };

            otherDialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => DialogHost.Show("Content", id));

            otherDialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));


            Assert.Equal("Multiple viable DialogHosts.  Specify a unique Identifier on each DialogHost, especially where multiple Windows are a concern.", ex.Message);
        }
 public DialogHostTests()
 {
     _dialogHost = new DialogHost();
     _dialogHost.ApplyDefaultStyle();
     _dialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
 }
示例#4
0
 public void Dispose()
 {
     _dialogHost.RaiseEvent(new RoutedEventArgs(FrameworkElement.UnloadedEvent));
 }