public void TryCreateWaitDialog_FailureToCreateDialog_ReturnsNull()
        {
            // Arrange
            IVsThreadedWaitDialog2 waitDialog2 = null;
            var vsWaitDialogFactory            = Mock.Of <IVsThreadedWaitDialogFactory>(factory => factory.CreateInstance(out waitDialog2) == VSConstants.E_FAIL, MockBehavior.Strict);
            var waitDialogFactory = new DefaultWaitDialogFactory(JoinableTaskContext, vsWaitDialogFactory);

            // Act
            var result = waitDialogFactory.TryCreateWaitDialog(title: null, message: null, (context) => Task.FromResult(true));

            // Assert
            Assert.Null(result);
        }
        public void TryCreateWaitDialog_Success()
        {
            // Arrange
            var vsWaitDialogFactory = CreateVSWaitDialogFactory();
            var waitDialogFactory   = new DefaultWaitDialogFactory(JoinableTaskContext, vsWaitDialogFactory);

            // Act
            var result = waitDialogFactory.TryCreateWaitDialog(title: null, message: null, async(context) =>
            {
                await Task.Delay(10, context.CancellationToken);
                return(1234);
            });

            // Assert
            Assert.False(result.Cancelled);
            Assert.Equal(1234, result.Result);
        }
        public void TryCreateWaitDialog_Cancelled()
        {
            // Arrange
            var dialog = new TestThreadedWaitDialog();
            var vsWaitDialogFactory = CreateVSWaitDialogFactory(dialog);
            var waitDialogFactory   = new DefaultWaitDialogFactory(JoinableTaskContext, vsWaitDialogFactory);

            // Act
            var result = waitDialogFactory.TryCreateWaitDialog(title: null, message: null, async(context) =>
            {
                await Task.Delay(10, context.CancellationToken);

                dialog.Cancel();

                await Task.Delay(10000, context.CancellationToken);
                return(true);
            });

            // Assert
            Assert.True(result.Cancelled);
            Assert.False(result.Result);
        }