Ejemplo n.º 1
0
        public void ExerciseCompositeViewModel_Receives_Cancel_Message_From_ExerciseEditViewModel()
        {
            ViewModelLocator compositeRoot = new ViewModelLocator();
            var viewModelFactory           = compositeRoot.ViewModelFactory;

            var exerciseService = new Mock <IExerciseService>();
            var dialogService   = new Mock <IDialogViewService>();

            var exercise = new Exercise {
                Id = 2, Title = "Existing Exercise"
            };

            exerciseService.Setup(srv => srv.Get(It.IsAny <int>()))
            .Returns(exercise);

            var exerciseManagementViewModel = new ExerciseManagementViewModel(exerciseService.Object, dialogService.Object);

            var exerciseEditViewModel = new ExerciseEditViewModel(dialogService.Object);

            var viewModel = new MockExerciseCompositeViewModel(viewModelFactory, exerciseService.Object, exerciseManagementViewModel, exerciseEditViewModel);

            exerciseEditViewModel.StartEdit(exercise);
            exerciseEditViewModel.CancelCommand.Execute(null);

            Assert.IsTrue(viewModel.EndEditinExerciseCalled);
            Assert.That(viewModel.EndEditOperation, Is.EqualTo(EditorCloseOperation.Canceled));
        }
Ejemplo n.º 2
0
        public void ExerciseCompositeViewModel_Receives_Save_Message_From_ExerciseEditViewModel()
        {
            var exerciseService = new Mock <IExerciseService>();
            var dialogService   = new Mock <IDialogViewService>();

            var exercise = new Exercise {
                Id = 0, Title = "New Exercise"
            };

            exerciseService.Setup(srv => srv.Get(It.IsAny <int>()))
            .Returns(exercise);

            var exerciseManagementViewModel = new ExerciseManagementViewModel(exerciseService.Object, dialogService.Object);
            var exerciseEditViewModel       = new ExerciseEditViewModel(dialogService.Object);
            var viewModelFactory            = new Mock <IViewModelFactory>();

            var viewModel = new MockExerciseCompositeViewModel(viewModelFactory.Object, exerciseService.Object, exerciseManagementViewModel, exerciseEditViewModel);

            exerciseEditViewModel.StartEdit(exercise);
            exerciseEditViewModel.SaveCommand.Execute(null);

            Assert.IsTrue(viewModel.EndEditinExerciseCalled);

            Assert.That(viewModel.EndEditOperation, Is.EqualTo(EditorCloseOperation.Saved));
        }