public void Save_Action_Will_Open_SaveDialog()
        {
            var dialogModel = new SaveFileDialogViewModel {Result = true};
            _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel));
            _viewModelFactory.Expect(x => x.Create<ISaveFileDialogViewModel>()).Return(dialogModel);

            var viewModel = CreateProjectViewModel();
            viewModel.Save();

            _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), x => x.Repeat.Once());
        }
        public void Calling_Save_For_Second_Time_Wont_Show_SaveDialog()
        {
            var dialogModel = new SaveFileDialogViewModel {Result = true, FileName = "C:\\"};
            var vm = CreateViewModel(dialogModel);

            vm.Save(); //For the first time, opens the dialog

            vm.Save(); //For the second time saves on the same file

            _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), options => options.Repeat.Once());
        }
Example #3
0
        private ISaveFileDialogViewModel CreateSaveFileDialogModel()
        {
            var model = new SaveFileDialogViewModel
            {
                AddExtension = true,
                CheckFileExists = true,
                CheckPathExists = true,
                OverwritePrompt = true,
                SupportMultiDottedExtensions = true,
                DefaultExtension = "rlic",
                Filter = "Rhino License Project|*.rlic",
                InitialDirectory = "C:\\",
                Title = "Save File Dialog",
            };

            return model;
        }
        public void Save_Action_Will_Call_ProjectService_If_Proper_Result_Is_Set()
        {
            var existingFile = Path.GetTempFileName();
            var choosenFile = new FileInfo(existingFile);
            var dialogViewModel = new SaveFileDialogViewModel {Result = true, FileName = existingFile};

            _viewModelFactory.Expect(x => x.Create<ISaveFileDialogViewModel>()).Return(dialogViewModel);
            _dialogService.Expect(x => x.ShowSaveFileDialog(dialogViewModel));

            var viewModel = CreateProjectViewModel();
            viewModel.Save();

            _projectService.Expect(x => x.Save(Arg<Project>.Is.Anything, Arg.Is(choosenFile))).Repeat.Once();
        }
        public void Export_Selected_License()
        {
            var licensepath = @"c:\License.xml";
            var vm = CreateProjectViewModel();
            var saveDialog = new SaveFileDialogViewModel { Result = true, FileName = licensepath };

            vm.CurrentProject = new Project {Product = new Product()};
            vm.SelectedLicense = new License { OwnerName = "John Doe", ExpirationDate = null, LicenseType = LicenseType.Trial };

            _viewModelFactory.Expect(f => f.Create<ISaveFileDialogViewModel>()).Return(saveDialog);

            vm.ExportLicense();

            _exportService.AssertWasCalled(x => x.Export(Arg.Is(vm.CurrentProject.Product), Arg.Is(vm.SelectedLicense), Arg<FileInfo>.Is.NotNull));
        }
        public void Calling_Save_For_Second_Time_Wont_Show_SaveDialog()
        {
            var dialogModel = new SaveFileDialogViewModel {Result = true, FileName = "C:\\"};
            _viewModelFactory.Expect(x => x.Create<ISaveFileDialogViewModel>()).Return(dialogModel);

            var vm = CreateProjectViewModel();
            
            vm.Save(); //For the first time, opens the dialog

            vm.Save(); //For the second time overwrites the same file

            _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), options => options.Repeat.Once());
        }
        public void Default_Project_Save_Dialog_Has_Correct_Filter()
        {
            var dialogViewModel = new SaveFileDialogViewModel { Result = true };
            _viewModelFactory.Expect(x => x.Create<ISaveFileDialogViewModel>()).Return(dialogViewModel);

            var vm = CreateProjectViewModel();
            vm.Save();

            Assert.Equal("Rhino Project|*.rlic", dialogViewModel.Filter);
        }
        public void Will_Not_Proceed_To_Save_When_No_File_Is_Selected()
        {
            var dialogModel = new SaveFileDialogViewModel {Result = true, FileName = null};

            _viewModelFactory.Expect(x => x.Create<ISaveFileDialogViewModel>()).Return(dialogModel);
            _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel));

            var viewModel = CreateProjectViewModel();
            viewModel.Save();
            
            _projectService.AssertWasNotCalled(x => x.Save(Arg<Project>.Is.Anything, Arg<FileInfo>.Is.Anything));
        }
        public void Save_Action_Will_Open_SaveDialog()
        {
            var dialogModel = new SaveFileDialogViewModel {Result = true};
            _dialogService.Expect(x => x.ShowSaveFileDialog(dialogModel));

            var vm = CreateViewModel(dialogModel);
            vm.Save();

            _dialogService.AssertWasCalled(x => x.ShowSaveFileDialog(Arg.Is(dialogModel)), x => x.Repeat.Once());
        }