コード例 #1
0
        public void MessengerPropertySet_MultipleLocomotivesPassed_HeaderSet()
        {
            _addDataParams.Setup(m => m.ReadLocomotives).
            Returns(new List <ILocomotive>()
            {
                new LocomotiveMock()
                {
                    Name = "Bobo"
                },
                new LocomotiveMock()
                {
                    Name = "Lulu"
                },
                new LocomotiveMock()
                {
                    Name = "Momo"
                }
            });

            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            Assert.That(_viewModel.Header, Is.EqualTo("Bobo, Lulu, Momo"));
        }
コード例 #2
0
        public void MessengerPropertySet_OneLocomotivePassed_HeaderSet()
        {
            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            Assert.That(_viewModel.Header, Is.EqualTo("Bobo"));
        }
コード例 #3
0
        public void MessengerPropertySet_FaultsAndPsnLogsStringSet()
        {
            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            Assert.That(_viewModel.FaultsString, Is.EqualTo("Копируется аварий: 2"));
            Assert.That(_viewModel.PsnLogString, Is.EqualTo("Копируется дампов магистрали ПСН: 2"));
        }
コード例 #4
0
        public void MessengerPropertySet_SaveDataAsyncCalledAndCanNotClose()
        {
            bool closeMessageSent = false;

            _messenger.Register <ViewMessage>(this, Views.Views.CopyProggress, message => { closeMessageSent = true; });

            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            _viewModel.Close.Execute(null);

            _repository.Verify();

            Assert.That(closeMessageSent, Is.False); // должно быть false, т.к процесс копирования не закончен
        }
コード例 #5
0
        public void MessengerPropertySet_CompleteResultIsError_ErrorDialogMessageSent()
        {
            InitializeSaveDataAsyncMock(true, OnCompleteEventArgs.CompleteResult.Error);

            bool dialogShown      = false;
            bool closeMessageSent = false;

            _messenger.Register <DialogMessage>(this, AppMessages.CopyProgressError, message => { dialogShown = true; });
            _messenger.Register <ViewMessage>(this, Views.Views.CopyProggress, message => { closeMessageSent = true; });

            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            _viewModel.Close.Execute(null);

            Assert.That(dialogShown, Is.True);
            Assert.That(closeMessageSent, Is.True);
        }
コード例 #6
0
        public void MessengerPropertySet_CompleteResultIsOk_FaultsStringSetAndCanClose()
        {
            InitializeSaveDataAsyncMock(true, OnCompleteEventArgs.CompleteResult.Ok);

            bool dialogShown      = false;
            bool closeMessageSent = false;

            _messenger.Register <DialogMessage>(this, AppMessages.CopyProgressError, message => { dialogShown = true; });
            _messenger.Register <ViewMessage>(this, Views.Views.CopyProggress, message => { closeMessageSent = true; });

            _viewModel = new CopyProgressViewModel(_repository.Object);
            _viewModel.StartMessaging(_messenger);
            _messenger.Send(new SetViewModelParametersMessage <IAddDataParameters>(_addDataParams.Object));

            _viewModel.Close.Execute(null);

            Assert.That(dialogShown, Is.False);
            Assert.That(closeMessageSent, Is.True);
            Assert.That(_viewModel.Progress, Is.EqualTo(100));
            Assert.That(_viewModel.FaultsString, Is.EqualTo("Скопировано аварий: 2"));
            Assert.That(_viewModel.PsnLogString, Is.EqualTo("Скопировано дампов магистрали ПСН: 2"));
        }