예제 #1
0
        public void HandleBusyMessageShouldNotUpdateMessageIfModeNone()
        {
            const string busyMessageString = "busy...";
            var          viewModel         = GetViewModelBase();

            viewModel.Settings.HandleBusyMessageMode = HandleMode.None;
            var busyMessage = new BeginBusyMessage(Guid.NewGuid(), busyMessageString);
            IHandler <BeginBusyMessage> beginBusyHandler = viewModel;

            beginBusyHandler.Handle(this, busyMessage);
            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
        }
예제 #2
0
 private void NotifyBeginBusy(IViewModel viewModel)
 {
     lock (_busyCollection)
     {
         if (_busyCollection.Count == 0)
         {
             return;
         }
         var isVmb = viewModel is ViewModelBase;
         foreach (var o in _busyCollection)
         {
             var message = new BeginBusyMessage(o.Key, o.Value);
             if (isVmb)
             {
                 ((IHandler <object>)viewModel).Handle(this, message);
             }
             else
             {
                 EventAggregator.Publish(viewModel, this, message);
             }
         }
     }
 }
예제 #3
0
        public void HandleBusyMessageShouldUpdateMessageAndNotifyListinersIfModeHandleAndNotifyListeners()
        {
            const string busyMessageString = "busy...";
            var          viewModel         = GetViewModelBase();
            var          childViewModel    = viewModel.GetViewModel <TestViewModelBase>(observationMode: ObservationMode.None);

            viewModel.Subscribe(childViewModel);
            viewModel.Settings.HandleBusyMessageMode = HandleMode.HandleAndNotifyObservers;
            var busyMessage = new BeginBusyMessage(Guid.NewGuid(), busyMessageString);
            IHandler <BeginBusyMessage> beginBusyHandler = viewModel;
            IHandler <EndBusyMessage>   endBusyHandler   = viewModel;

            beginBusyHandler.Handle(this, busyMessage);
            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(busyMessageString);
            childViewModel.IsBusy.ShouldBeTrue();
            childViewModel.BusyMessage.ShouldEqual(busyMessageString);

            endBusyHandler.Handle(this, busyMessage.ToEndBusyMessage());
            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
            childViewModel.IsBusy.ShouldBeFalse();
            childViewModel.BusyMessage.ShouldBeNull();
        }