Exemplo n.º 1
0
        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);
                                                                                });
        }
Exemplo n.º 2
0
        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");
            });
        }
Exemplo n.º 3
0
 protected ICommand DecorateCommand(ActionBase action)
 {
     action.SetViewModel(this);
     return action;
 }
Exemplo n.º 4
0
 public void SetUp()
 {
     formViewModel = new FormViewModel();
     command = new ValidationQuery(null);
     command.SetViewModel(formViewModel);
 }