public void TestConstructionFromTemplate()
        {
            var id = Guid.NewGuid();
            var widgetConfiguration = new QuickInfoWidgetConfiguration();

            widgetConfiguration.Add(new QuickInfoViewConfiguration(id)
            {
                Name = "Cool entry"
            });
            var template = new WidgetTemplate
            {
                Configuration = widgetConfiguration
            };
            var analyser = new Mock <IDataSourceAnalyser>();
            var analyserConfiguration = new QuickInfoAnalyserConfiguration();

            analyserConfiguration.Add(new QuickInfoConfiguration(id)
            {
                FilterValue = "Foo"
            });
            analyser.Setup(x => x.Configuration).Returns(analyserConfiguration);

            var viewModel = new QuickInfoWidgetViewModel(template, analyser.Object);

            viewModel.QuickInfos.Should().HaveCount(1);
            var quickInfo = viewModel.QuickInfos.First();

            quickInfo.Should().NotBeNull();
            quickInfo.Id.Should().Be(id);
            quickInfo.Name.Should().Be("Cool entry");
            quickInfo.FilterValue.Should().Be("Foo");
        }
        public void TestRoundtripEmpty()
        {
            var config       = new QuickInfoAnalyserConfiguration();
            var actualConfig = config.Roundtrip();

            actualConfig.Should().NotBeNull();
            actualConfig.QuickInfos.Should().BeEmpty();
        }
        public QuickInfoWidgetViewModel(IWidgetTemplate template,
                                        IDataSourceAnalyser dataSourceAnalyser)
            : base(template, dataSourceAnalyser)
        {
            _viewConfiguration     = template.Configuration as QuickInfoWidgetConfiguration;
            _analyserConfiguration = AnalyserConfiguration as QuickInfoAnalyserConfiguration;

            _quickInfosById      = new Dictionary <Guid, QuickInfoViewModel>();
            _quickInfos          = new ObservableCollection <QuickInfoViewModel>();
            _addQuickInfoCommand = new DelegateCommand2(AddQuickInfo);

            PropertyChanged += OnPropertyChanged;
        }
        public void TestAdd()
        {
            var config = new QuickInfoAnalyserConfiguration();

            config.QuickInfos.Should().BeEmpty();

            var id   = Guid.NewGuid();
            var info = new QuickInfoConfiguration(id);

            config.Add(info);
            config.QuickInfos.Should().HaveCount(1);
            config.QuickInfos.First().Should().BeSameAs(info);
        }
        public void TestRoundtripOneQuickInfo()
        {
            var config = new QuickInfoAnalyserConfiguration();
            var id     = Guid.NewGuid();

            config.Add(new QuickInfoConfiguration(id)
            {
                FilterValue = "ERROR: ",
                MatchType   = FilterMatchType.TimeFilter
            });

            var actualConfig = config.Roundtrip(typeof(QuickInfoConfiguration));

            actualConfig.Should().NotBeNull();
            actualConfig.QuickInfos.Should().HaveCount(1);
            actualConfig.QuickInfos.First().Id.Should().Be(id);
            actualConfig.QuickInfos.First().FilterValue.Should().Be("ERROR: ");
            actualConfig.QuickInfos.First().MatchType.Should().Be(FilterMatchType.TimeFilter);
        }
        public void TestAdd()
        {
            var widgetConfiguration = new QuickInfoWidgetConfiguration();
            var template            = new WidgetTemplate
            {
                Configuration = widgetConfiguration
            };
            var analyser = new Mock <IDataSourceAnalyser>();
            var analyserConfiguration = new QuickInfoAnalyserConfiguration();

            analyser.Setup(x => x.Configuration).Returns(analyserConfiguration);
            var viewModel = new QuickInfoWidgetViewModel(template, analyser.Object);

            viewModel.MonitorEvents();

            viewModel.AddQuickInfoCommand.Execute(null);
            widgetConfiguration.Titles.Should().HaveCount(1, "because we've just added one new element");
            //analyserConfiguration.QuickInfos.Should().HaveCount(1, "because we've just added one new element");
            viewModel.ShouldRaise(nameof(QuickInfoWidgetViewModel.TemplateModified));
        }
        public QuickInfoWidgetViewModel(IWidgetTemplate template,
                                        IDataSourceAnalyser dataSourceAnalyser)
            : base(template, dataSourceAnalyser)
        {
            _viewConfiguration     = template.Configuration as QuickInfoWidgetConfiguration ?? new QuickInfoWidgetConfiguration();
            _analyserConfiguration = AnalyserConfiguration as QuickInfoAnalyserConfiguration ?? new QuickInfoAnalyserConfiguration();

            _quickInfosById      = new Dictionary <Guid, QuickInfoViewModel>();
            _quickInfos          = new ObservableCollection <QuickInfoViewModel>();
            _addQuickInfoCommand = new DelegateCommand2(AddQuickInfo);

            foreach (var quickInfo in _viewConfiguration.Titles)
            {
                var analysis = _analyserConfiguration.QuickInfos.FirstOrDefault(x => x.Id == quickInfo.Id);
                if (analysis != null)
                {
                    AddQuickInfo(quickInfo.Id, quickInfo, analysis);
                }
            }

            PropertyChanged += OnPropertyChanged;
        }