public void NewStateAdded_UndoPerformed_NoStatesInViewModel() { var viewModel = new StateMachineDialogWindowViewModel(new StateMachine(), Substitute.For <IViewService>()); viewModel.StateMachineViewModel.AddNewState(CreateStateFactory(), new System.Windows.Point(0, 0)); Assert.Equal(1, viewModel.StateMachineViewModel.States.Count); viewModel.UndoCommand.Execute(null); Assert.Equal(0, viewModel.StateMachineViewModel.States.Count); }
public void TransitionDeleted_UndoPerformed_TransitionReturned() { var stateMachine = CreateStateMachineWithStatesAndTransition(); var viewModel = new StateMachineDialogWindowViewModel(stateMachine, Substitute.For <IViewService>()); viewModel.StateMachineViewModel.Transitions[0].DeleteCommand.Execute(null); viewModel.UndoCommand.Execute(null); Assert.NotEmpty(viewModel.StateMachineViewModel.Transitions); }
public void TrasitionCreatedAndRenamed_UndoPerformed_TransitionProperNameSet() { var stateMachine = CreateStateMachineWithStatesAndTransition(); stateMachine.Transitions[0].Name = "Name1"; var viewModel = new StateMachineDialogWindowViewModel(stateMachine, Substitute.For <IViewService>()); viewModel.StateMachineViewModel.Transitions[0].Name = "Name2"; viewModel.UndoCommand.Execute(null); Assert.Equal("Name1", viewModel.StateMachineViewModel.Transitions[0].Name); }
public void StateMachineNameChanged_UndoPerformed_OriginalNameAssigned() { var stateMachine = new StateMachine() { Name = "Name1" }; var viewModel = new StateMachineDialogWindowViewModel(stateMachine, Substitute.For <IViewService>()); viewModel.StateMachineViewModel.Name = "Name2"; viewModel.UndoCommand.Execute(null); Assert.Equal(viewModel.StateMachineViewModel.Name, "Name1"); }
public void StateMachineNameChanged_UndoAndRedoPerformed_ProperStateMachineNameIsSet() { var stateMachine = new StateMachine { States = new[] { new State { Name = "Name1" } } }; var viewModel = new StateMachineDialogWindowViewModel(stateMachine, Substitute.For <IViewService>()); viewModel.StateMachineViewModel.States[0].Name = "Name2"; viewModel.UndoCommand.Execute(null); viewModel.RedoCommand.Execute(null); Assert.Equal(viewModel.StateMachineViewModel.States[0].Name, "Name2"); }
public void AddTransition_DeleteTransition_TransitionDeleted() { Guid guid1 = Guid.NewGuid(); Guid guid2 = Guid.NewGuid(); var stateMachine = new StateMachine { Transitions = new[] { new StateMachineTransition { Name = "Name1", SourceStateId = guid1, TargetStateId = guid2 } }, States = new[] { new State { Id = guid1 }, new State { Id = guid2 } } }; var vm = new StateMachineDialogWindowViewModel(stateMachine, Substitute.For <IViewService>()); TransitionViewModel transition = vm.StateMachineViewModel.Transitions[0]; transition.DeleteCommand.Execute(null); Assert.Empty(vm.StateMachineViewModel.Transitions); }