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);
        }
        public void NewDocumentDialogViewModelCloseTest()
        {
            MockDocumentType documentType = new MockDocumentType("Mock Document Type", ".mock");

            MockNewDocumentDialogView view = new MockNewDocumentDialogView();
            NewDocumentDialogViewModel viewModel = new NewDocumentDialogViewModel(
                view,
                new List<IDocumentType>() { documentType });

            Assert.AreEqual("NewFile", viewModel.FileName);
            Assert.AreEqual(documentType, viewModel.SelectDocumentType);

            object owner = new object();
            bool showDialogCalled = false;
            view.ShowDialogAction = v =>
            {
                showDialogCalled = true;

                //  Cancel
                v.Close();
            };
            bool? dialogResult = viewModel.ShowDialog(owner);
            Assert.IsNull(dialogResult);
            Assert.IsTrue(showDialogCalled);

            showDialogCalled = false;
            view.ShowDialogAction = v =>
            {
                showDialogCalled = true;
                v.ViewModel.FileName = "NewMockFile";
                v.ViewModel.SelectDocumentType = documentType;

                v.ViewModel.OKCommand.Execute(null);
            };
            dialogResult = viewModel.ShowDialog(owner);
            Assert.IsTrue(showDialogCalled);
            Assert.AreEqual(true, dialogResult);
            Assert.AreEqual("NewMockFile", viewModel.FileName);
            Assert.AreEqual(documentType, viewModel.SelectDocumentType);
        }
 public MockDocument(MockDocumentType documentType)
     : base(documentType)
 {
 }