Пример #1
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();
        }
Пример #2
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); }
        }
Пример #3
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); }
        }
Пример #4
0
        public async void Activate_ShouldSubscribeForAlarms()
        {
            AlarmSummaryViewModel viewModel = CreateViewModel();
            await viewModel.Activate();

            _provideAlarms.Verify(p => p.SubscribeForAlarmChanges(new Collection <string> {
                _randomModule
            }, viewModel.UpdateAlarms));
        }
Пример #5
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();
            }
        }
Пример #7
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); }
        }
Пример #8
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 });
        }
Пример #9
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 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();
        }