public void IfNoExceptionsOccurThenShouldSetViewModelStateToLoadingThenToStill() { command = new Query(p => { }); command.SetViewModel(viewModel); var events = new List<string>(); const string still = "BackToStill"; subscriber.SubscribeTo(vm => vm.State, () => { if (viewModel.State == ViewModelState.Loading) { events.Add(loading); } if (viewModel.State == ViewModelState.Still) { events.Add(still); } }); Task.Factory.StartNew(() => command.Execute(null)).ContinueWith(prev => { Assert.True(events.Count == 2); Assert.True(events[0] == loading); Assert.True(events[1] == still); }); }
public void IfExceptionsOccuredThenShouldSetViewModelStateToUploadingThenToFaulted() { command = new Command(p => { throw new EventLogReadingException(); }); command.SetViewModel(viewModel); var events = new List<string>(); subscriber.SubscribeTo(vm => vm.State, () => { if (viewModel.State == ViewModelState.Uploading) { events.Add("Uploading"); } if (viewModel.State == ViewModelState.Faulted) { events.Add("Faulted"); } }); Task.Factory.StartNew(() => command.Execute(null)).ContinueWith(prev => { Assert.True(events.Count == 2); Assert.True(events[0] == "Uploading"); Assert.True(events[1] == "Faulted"); }); }
protected ICommand DecorateCommand(ActionBase action) { action.SetViewModel(this); return action; }
public void SetUp() { viewModel = new TestViewModel(); subscriber = new PropertySubscriber<TestViewModel>(viewModel); command = new Command(p => {}); }
public void SetUp() { formViewModel = new FormViewModel(); command = new ValidationQuery(null); command.SetViewModel(formViewModel); }