public void TestConstructionFromNonEmptyTemplate()
        {
            _template.Layout = new HorizontalWidgetLayoutTemplate();
            var plugin = CreateWidgetPlugin();

            _pluginRegistry.Register(plugin);

            var analyser = AddAnalyser();

            _template.Add(new WidgetTemplate
            {
                AnalyserId       = analyser.Id,
                AnalyserPluginId = plugin.AnalyserId
            });

            var model = new AnalysisPageViewModel(_id, _template, _analyser.Object, _analysisStorage.Object, _pluginRegistry);

            model.Name.Should().NotBeEmpty();
            model.HasWidgets.Should().BeTrue("because we've created this page using a template with one widget");

            model.PageLayout.Should().Be(PageLayout.WrapHorizontal);
            model.Layout.Should().NotBeNull();
            model.Layout.Should().BeOfType <HorizontalWrapWidgetLayoutViewModel>();
            var layout = (HorizontalWrapWidgetLayoutViewModel)model.Layout;

            layout.Widgets.Should().HaveCount(1);

            _template.Widgets.Should().HaveCount(1, "because the page template musn't have been modified");
            _analysisStorage.Verify(x => x.SaveAsync(It.IsAny <AnalysisId>()), Times.Never,
                                    "because we've just create a view model from an existing template and NOT made any changes to said template. Therefore nothing should've been saved to disk");
        }
Exemplo n.º 2
0
        public void TestClone3()
        {
            var template = new PageTemplate();
            var widget   = new WidgetTemplate();

            template.Add(widget);

            var clone = template.Clone();

            clone.Should().NotBeNull();
            clone.Should().NotBeSameAs(template);
            clone.Layout.Should().BeNull();
            clone.Widgets.Should().HaveCount(1);
            clone.Widgets.ElementAt(0).Should().NotBeNull();
            clone.Widgets.ElementAt(0).Should().NotBeSameAs(widget);
        }
Exemplo n.º 3
0
        private void LayoutOnRequestAddWidget(IWidgetPlugin plugin)
        {
            var viewConfiguration = CreateViewConfiguration(plugin);

            var configuration = plugin.DefaultAnalyserConfiguration?.Clone() as ILogAnalyserConfiguration;
            var analyser      = CreateAnalyser(plugin.AnalyserId, configuration);

            var widgetTemplate = new WidgetTemplate
            {
                Id            = WidgetId.CreateNew(),
                AnalyserId    = analyser.Id,
                Configuration = viewConfiguration
            };
            var widget = plugin.CreateViewModel(widgetTemplate, analyser);

            _analysersPerWidget.Add(widget, analyser);
            _template.Add(widgetTemplate);

            Add(widget);
        }