Exemplo n.º 1
0
        public void ClearBusyShouldNotifyListiners()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel      = GetViewModelBase();
            var           childViewModel = viewModel.GetViewModel <TestViewModelBase>(observationMode: ObservationMode.None);

            viewModel.Subscribe(childViewModel);
            viewModel.Settings.HandleBusyMessageMode = HandleMode.HandleAndNotifySubscribers;

            viewModel.BeginBusy(firstBusyMessage);
            viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            viewModel.BusyInfo.GetMessages().Count.ShouldEqual(2);
            childViewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            childViewModel.IsBusy.ShouldBeTrue();
            childViewModel.BusyInfo.GetMessages().Count.ShouldEqual(2);
            viewModel.ClearBusy();

            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
            viewModel.BusyInfo.ShouldBeNull();
            childViewModel.IsBusy.ShouldBeFalse();
            childViewModel.BusyMessage.ShouldBeNull();
            childViewModel.BusyInfo.ShouldBeNull();
        }
Exemplo n.º 2
0
        public void WhenVmAddedToListenersItShouldGetAllBusyMessage()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel = GetViewModelBase();

            viewModel.BeginBusy(firstBusyMessage);
            viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            var messages = viewModel.BusyInfo.GetMessages();

            messages.Count.ShouldEqual(2);
            messages[0].ShouldEqual(firstBusyMessage);
            messages[1].ShouldEqual(secondBusyMessage);

            var testViewModelBase = viewModel.GetViewModel <TestViewModelBase>(observationMode: ObservationMode.None);

            viewModel.Subscribe(testViewModelBase);

            testViewModelBase.IsBusy.ShouldBeTrue();
            testViewModelBase.BusyMessage.ShouldEqual(secondBusyMessage);
            messages = testViewModelBase.BusyInfo.GetMessages();
            messages.Count.ShouldEqual(2);
            messages[0].ShouldEqual(firstBusyMessage);
            messages[1].ShouldEqual(secondBusyMessage);
        }
Exemplo n.º 3
0
        public void SeveralBusyMessagesShouldBeDisplayedInOrderOfRegistration()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel = GetViewModelBase();
            var           firstId   = viewModel.BeginBusy(firstBusyMessage);
            var           secondId  = viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            var messages = viewModel.BusyInfo.GetMessages();

            messages.Count.ShouldEqual(2);
            messages[0].ShouldEqual(firstBusyMessage);
            messages[1].ShouldEqual(secondBusyMessage);
            secondId.Dispose();

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(firstBusyMessage);
            viewModel.BusyInfo.GetMessages().Single().ShouldEqual(firstBusyMessage);
            firstId.Dispose();

            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
            viewModel.BusyInfo.ShouldBeNull();
        }
Exemplo n.º 4
0
        public void GetBusyTokensShouldReturnAllBusyMessages()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel = GetViewModelBase();

            viewModel.GetBusyTokens().ShouldBeEmpty();

            viewModel.BeginBusy(firstBusyMessage);
            viewModel.GetBusyTokens().Single().Message.ShouldEqual(firstBusyMessage);

            viewModel.BeginBusy(secondBusyMessage);
            var tokens = viewModel.GetBusyTokens();

            tokens.Count.ShouldEqual(2);
            tokens[1].Message.ShouldEqual(secondBusyMessage);

            foreach (var token in tokens)
            {
                token.Dispose();
            }
            viewModel.GetBusyTokens().ShouldBeEmpty();
            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
        }
Exemplo n.º 5
0
        public void WhenVmRemovedFromListenersItShouldRemoveAllBusyMessageFromVm()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel      = GetViewModelBase();
            var           childViewModel = viewModel.GetViewModel <TestViewModelBase>(observationMode: ObservationMode.None);

            viewModel.Subscribe(childViewModel);

            viewModel.Settings.HandleBusyMessageMode = HandleMode.HandleAndNotifyObservers;

            viewModel.BeginBusy(firstBusyMessage);
            viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            childViewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            childViewModel.IsBusy.ShouldBeTrue();

            viewModel.Unsubscribe(childViewModel);
            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            childViewModel.IsBusy.ShouldBeFalse();
            childViewModel.BusyMessage.ShouldBeNull();
        }
Exemplo n.º 6
0
        public void ClearBusyShouldRemoveAllBusyMessages()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel = GetViewModelBase();

            viewModel.BeginBusy(firstBusyMessage);
            viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            viewModel.ClearBusy();

            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
        }
Exemplo n.º 7
0
        public void SeveralBusyMessagesShouldBeDisplayedInOrderOfRegistration()
        {
            const string firstBusyMessage  = "busy1...";
            const string secondBusyMessage = "busy2...";

            ViewModelBase viewModel = GetViewModelBase();
            var           firstId   = viewModel.BeginBusy(firstBusyMessage);
            var           secondId  = viewModel.BeginBusy(secondBusyMessage);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(secondBusyMessage);
            viewModel.EndBusy(secondId);

            viewModel.IsBusy.ShouldBeTrue();
            viewModel.BusyMessage.ShouldEqual(firstBusyMessage);
            viewModel.EndBusy(firstId);

            viewModel.IsBusy.ShouldBeFalse();
            viewModel.BusyMessage.ShouldBeNull();
        }
Exemplo n.º 8
0
        public void DefaultBusyMessageShouldEqualsToSettingsDefaultBusyMessage()
        {
            const string busyMessage = "busy...";

            Settings.WithoutClone       = true;
            Settings.DefaultBusyMessage = busyMessage;
            ViewModelBase viewModel = GetViewModelBase();

            viewModel.BeginBusy();
            viewModel.BusyMessage.ShouldEqual(busyMessage);
        }
Exemplo n.º 9
0
        public void DefaultBusyMessageShouldEqualsToSettingsDefaultBusyMessage()
        {
            const string busyMessage = "busy...";
            var          settings    = new DefaultViewModelSettings {
                DefaultBusyMessage = busyMessage
            };

            ToolkitServiceProvider.ViewModelSettingsFactory = model => settings;

            ViewModelBase viewModel = GetViewModelBase();

            viewModel.BeginBusy();
            viewModel.BusyMessage.ShouldEqual(busyMessage);
        }