예제 #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);
                                                                                });
        }
예제 #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");
            });
        }
예제 #3
0
 protected ICommand DecorateCommand(ActionBase action)
 {
     action.SetViewModel(this);
     return action;
 }
예제 #4
0
        public void SetUp()
        {
            viewModel = new TestViewModel();
            subscriber = new PropertySubscriber<TestViewModel>(viewModel);

            command = new Command(p => {});
        }
예제 #5
0
 public void SetUp()
 {
     formViewModel = new FormViewModel();
     command = new ValidationQuery(null);
     command.SetViewModel(formViewModel);
 }