public NewSolutionDialogInfrastructure Create() { NewSolutionDialog model = new NewSolutionDialog(); NewSolutionDialogViewModel viewModel = new NewSolutionDialogViewModel(model); NewSolutionDialogView view = new NewSolutionDialogView(viewModel); return(new NewSolutionDialogInfrastructure(model, viewModel, view)); }
public NewSolutionDialogInfrastructure( NewSolutionDialog model, NewSolutionDialogViewModel viewModel, NewSolutionDialogView view ) { Model = model; ViewModel = viewModel; View = view; }
public void NewSolutionDialogViewModelCloseTest() { MockNewSolutionDialogView view = new MockNewSolutionDialogView(); NewSolutionDialogViewModel viewModel = new NewSolutionDialogViewModel(view); //Assert.AreEqual(String.Empty, viewModel.Location); Assert.AreEqual("NewSolution", viewModel.SolutionName); 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.Location = Environment.CurrentDirectory; v.ViewModel.SolutionName = "TestSolution"; v.ViewModel.OKCommand.Execute(null); }; dialogResult = viewModel.ShowDialog(owner); Assert.IsTrue(showDialogCalled); Assert.AreEqual(true, dialogResult); Assert.AreEqual(Environment.CurrentDirectory, viewModel.Location); Assert.AreEqual("TestSolution", viewModel.SolutionName); }
internal SolutionDocument NewSolution() { // Show the new solutiion view to the user INewSolutionDialogView newSolutionView = container.GetExportedValue<INewSolutionDialogView>(); if (!Directory.Exists(Settings.Default.DefaultNewSolutionLocation)) { Settings.Default.DefaultNewSolutionLocation = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ApplicationInfo.ProductName); Directory.CreateDirectory(Settings.Default.DefaultNewSolutionLocation); } NewSolutionDialogViewModel newSolutionViewModel = new NewSolutionDialogViewModel(newSolutionView); bool? dialogResult = newSolutionViewModel.ShowDialog(shellService.ShellView); if (dialogResult == true) { if (!CloseSolution()) { return SolutionDoc; } SolutionDocumentType documentType = new SolutionDocumentType(); return NewSolutionCore(Path.Combine(newSolutionViewModel.Location, newSolutionViewModel.SolutionName, newSolutionViewModel.SolutionName + documentType.FileExtension)); } else return null; }