public void SaveChangesDialogViewModelCloseTest()
        {
            MockDocumentType documentType = new MockDocumentType("Mock Document", ".mock");
            IEnumerable<IDocument> documents = new IDocument[]
            {
                documentType.New(Path.Combine(Environment.CurrentDirectory, "Test1")),
                documentType.New(Path.Combine(Environment.CurrentDirectory, "Test2")),
                documentType.New(Path.Combine(Environment.CurrentDirectory, "Test3"))
            };

            MockSaveChangesDialogView view = new MockSaveChangesDialogView();
            SaveChangesDialogViewModel viewModel = new SaveChangesDialogViewModel(view, documents);

            Assert.AreEqual(documents, viewModel.Documents);

            object owner = new object();
            view.ShowDialogAction = v =>
            {
                viewModel.YesCommand.Execute(null);
            };
            bool? dialogResult = viewModel.ShowDialog(owner);
            Assert.AreEqual(true, dialogResult);

            view.ShowDialogAction = v =>
            {
                viewModel.NoCommand.Execute(null);
            };
            dialogResult = viewModel.ShowDialog(owner);
            Assert.AreEqual(false, dialogResult);
        }
        private bool CanDocumentsClose(IEnumerable<IDocument> documentsToClose)
        {
            List<IDocument> modifiedDocuments = documentsToClose.Where(d => d.Modified).ToList();
            if (!modifiedDocuments.Any()) { return true; }

            // Show the save changes view to the user
            ISaveChangesDialogView saveChangesView = container.GetExportedValue<ISaveChangesDialogView>();
            SaveChangesDialogViewModel saveChangesViewModel = new SaveChangesDialogViewModel(saveChangesView, modifiedDocuments);
            bool? dialogResult = saveChangesViewModel.ShowDialog(shellService.ShellView);

            if (dialogResult == true)
            {
                foreach (IDocument document in modifiedDocuments)
                {
                    SaveDocument(document);
                }
            }

            return dialogResult != null;
        }