示例#1
0
        public void AcceptAlerts_OnThrowingReseter_ShouldNotThrow()
        {
            _resetAlarms.Setup(r => r.ResetAlarms(It.IsAny <string>())).Throws(new Exception());
            AlarmSummaryViewModel viewModel = CreateViewModel();

            viewModel.Invoking(vm => vm.AcceptAlerts()).ShouldNotThrow <Exception>();
        }
 /// <summary>
 /// Called when deactivating.
 /// </summary>
 /// <param name="close">Inidicates whether this instance will be closed.</param>
 protected async override void OnDeactivate(bool close)
 {
     if (AlarmSummaryViewModel != null)
     {
         await AlarmSummaryViewModel.Deactivate();
     }
 }
示例#3
0
        public void AcceptAlerts_ShouldDelegateToReseter()
        {
            AlarmSummaryViewModel viewModel = CreateViewModel();

            viewModel.AcceptAlerts();
            _resetAlarms.Verify(r => r.ResetAlarms(_randomModule));
        }
示例#4
0
        public async void Activate_OnViewModelGettingExceptionWhenSubscribingForAlarmChanges_ShouldNotThrow()
        {
            _provideAlarms.Setup(p => p.SubscribeForAlarmChanges(It.IsAny <ICollection <string> >(), It.IsAny <Action <IEnumerable <Alarm>, IEnumerable <Alarm> > >())).Throws(new Exception());
            AlarmSummaryViewModel viewModel = CreateViewModel();

            try { await viewModel.Activate(); }
            catch (Exception exception) { Assert.Fail("Should not have thrown exception {0}.", exception); }
        }
示例#5
0
        public async void Activate_OnViewModelGettingExceptionWhenGettingLogMessages_ShouldNotThrow()
        {
            _provideLogMessages.Setup(p => p.GetMessages(It.IsAny <IEnumerable <string> >())).Throws(new Exception());
            AlarmSummaryViewModel viewModel = CreateViewModel();

            try { await viewModel.Activate(); }
            catch (Exception exception) { Assert.Fail("Should not have thrown exception {0}.", exception); }
        }
示例#6
0
        public async void Activate_ShouldSubscribeForAlarms()
        {
            AlarmSummaryViewModel viewModel = CreateViewModel();
            await viewModel.Activate();

            _provideAlarms.Verify(p => p.SubscribeForAlarmChanges(new Collection <string> {
                _randomModule
            }, viewModel.UpdateAlarms));
        }
示例#7
0
        public async void Activate_ShouldRequestAlarms()
        {
            AlarmSummaryViewModel viewModel = CreateViewModel();
            await viewModel.Activate();

            _provideAlarms.Verify(p => p.RequestAlarms(new Collection <string> {
                _randomModule
            }));
        }
        /// <summary>
        /// Activates this instance.
        /// </summary>
        protected async override void OnActivate()
        {
            base.OnActivate();

            if (AlarmSummaryViewModel != null)
            {
                await AlarmSummaryViewModel.Activate();
            }
        }
示例#9
0
        public void UpdateAlarms_WithOneCurrentAndOneHistoricAlarm_ShouldExposeBoth()
        {
            var currentAlarm  = new Alarm();
            var historicAlarm = new Alarm();
            AlarmSummaryViewModel viewModel = CreateViewModel();

            viewModel.UpdateAlarms(new[] { currentAlarm }, new[] { historicAlarm });
            viewModel.CurrentAlarmEntries.Should().Contain(currentAlarm);
            viewModel.HistoricAlarmEntries.Should().Contain(historicAlarm);
        }
示例#10
0
        public async void Activate_OnViewModelGettingExceptionWhenRequestingAlarms_ShouldNotThrow()
        {
            _provideAlarms
            .Setup(p => p.RequestAlarms(It.IsAny <ICollection <string> >()))
            .Throws(new Exception());
            AlarmSummaryViewModel viewModel = CreateViewModel();

            try { await viewModel.Activate(); }
            catch (Exception exception) { Assert.Fail("Should not have thrown exception {0}.", exception); }
        }
示例#11
0
 /// <summary>
 /// Called when deactivating.
 /// </summary>
 /// <param name="close">Inidicates whether this instance will be closed.</param>
 protected async override void OnDeactivate(bool close)
 {
     RemoveMessage(Common.PlatformEssentials.MessageType.Error,
                   "The module was not properly initialized.\n Please restart the application!");
     base.OnDeactivate(close);
     if (AlarmSummaryViewModel != null)
     {
         await AlarmSummaryViewModel.Deactivate();
     }
 }
示例#12
0
        public async void Activate_OnViewModelGettingTwoLogMessages_ShouldExposeBoth()
        {
            string secondMessage          = CreateRandom.String();
            IEnumerable <string> messages = new[] { _firstMessage, secondMessage };

            _provideLogMessages.Setup(p => p.GetMessages(It.IsAny <IEnumerable <string> >())).Returns(Task.FromResult(messages));
            AlarmSummaryViewModel viewModel = CreateViewModel();
            await viewModel.Activate();

            viewModel.LogMessages.Should().Contain(new[] { _firstMessage, secondMessage });
        }
示例#13
0
        public async void Activate_ShouldGetLogMessages()
        {
            string[] randomLogFilters = { CreateRandom.String() };
            _provideLogFilters
            .Setup(p => p.GetLogFiltersForModule(_randomModule))
            .Returns(randomLogFilters);
            AlarmSummaryViewModel viewModel = CreateViewModel();

            await viewModel.Activate();

            _provideLogMessages.Verify(p => p.GetMessages(randomLogFilters));
        }
 public ModuleControlScreenMock()
 {
     Throughput            = 1187.4;
     ThroughputMin         = 0;
     ThroughputMax         = 3000;
     CurrentItemCount      = 5449;
     UpTime                = 250;
     DownTime              = 43;
     State                 = "Run";
     SubState              = "Wait Operator";
     ModuleState           = WpfInfrastructure.Screens.Model.ModuleState.Run;
     AlarmSummaryViewModel = new AlarmSummaryViewModel();
 }
示例#15
0
        public async void Activate_OnViewModelWithMessage_ShouldReplaceMessages()
        {
            IEnumerable <string> messagesOnFirstGet  = new[] { _firstMessage };
            IEnumerable <string> messagesOnSecondGet = new string[] {};

            _provideLogMessages.Setup(p => p.GetMessages(It.IsAny <IEnumerable <string> >())).Returns(Task.FromResult(messagesOnFirstGet));
            AlarmSummaryViewModel viewModel = CreateViewModel();
            await viewModel.Activate();

            _provideLogMessages.Setup(p => p.GetMessages(It.IsAny <IEnumerable <string> >())).Returns(Task.FromResult(messagesOnSecondGet));
            await viewModel.Activate();

            viewModel.LogMessages.Should().BeEmpty();
        }
        public override async Task Initialize()
        {
            await EnsureValidConfigurationServiceWcfConnection();
            await EnsureValidCommonServicesWcfConnection();

            IList <ModuleVertexViewModelBase> nodePositions = new List <ModuleVertexViewModelBase>();

            string positionsXml = String.Empty;

            try
            {
                positionsXml = await _configurationServiceClient.GetValueAsync(VertexPositionsConfig);
            }
            catch (FaultException e)
            {
                _logger.Error("Could not load vertex positions from remote config", e);
            }

            if (!String.IsNullOrEmpty(positionsXml))
            {
                var serializer        = new XmlSerializer(typeof(List <ModuleVertexViewModelBase>));
                var stringReaderPaper = new StringReader(positionsXml);
                nodePositions = (List <ModuleVertexViewModelBase>)serializer.Deserialize(stringReaderPaper);
            }

            var graphDto = await GetModuleGraphFromServer();

            ModuleGraph = GraphBuilder.BuildGraph(_logger, graphDto, nodePositions, true);

            _logger.Debug("Creating AlarmSummaryViewModel for HomeScreen");

            var modules = new Collection <string>();

            foreach (var vertice in ModuleGraph.Vertices)
            {
                modules.Add(vertice.ID);
            }

            AlarmSummaryViewModel = _alarmManagementFactory.CreateAlarmSummaryViewModel(modules);
            AlarmSummaryViewModel.CurrentAlarmsChanged += AlarmSummaryViewModelCurrentAlarmsChanged;
            await AlarmSummaryViewModel.Activate();
        }