Beispiel #1
0
        public void DummyGridSystemInitializer_AddLayoutControl_VerifyControlIsProperlyAddedToTheToolbox()
        {
            //Arrange: Initialize the GridSystemInitializer, ToolboxesConfig and add a PageLayouts section, create a layouts section, create a dummy grid controls
            DummyGridSystemInitializer initializer = new DummyGridSystemInitializer();
            var fakeTemplatePath = "~/fakeTemplatePath/";
            var dummyData        = initializer.PublicCreateLayoutControlsData(fakeTemplatePath);
            var toolboxesConfig  = new DummyToolboxesConfig();
            var pageControlsMock = new Toolbox(toolboxesConfig.Toolboxes);

            pageControlsMock.Name = "PageLayouts";
            toolboxesConfig.Toolboxes.Add("PageLayouts", pageControlsMock);
            var htmlLayoutsSection = initializer.PublicCreateToolBoxSection(toolboxesConfig);
            var parentToolboxItem  = htmlLayoutsSection.Tools;

            //Act: add the grid controls to the toolbox
            foreach (var gridControl in dummyData)
            {
                initializer.PublicAddLayoutControl(parentToolboxItem, gridControl);
            }

            //Assert: Verify the newly created controls are properly created
            Assert.AreEqual <int>(dummyData.Count, parentToolboxItem.Count, "Not all grid controls were added to the toolbox.");

            var oneColumnGridControl = dummyData.FirstOrDefault();

            var oneColumnGridToolboxItem = parentToolboxItem.Where <ToolboxItem>(toolboxItem => toolboxItem.Name == oneColumnGridControl.Name).FirstOrDefault();

            Assert.IsNotNull(oneColumnGridToolboxItem, "The grid control was not added to the toolbox.");
            Assert.AreEqual <string>(oneColumnGridControl.Title, oneColumnGridToolboxItem.Title, "The grid control toolbox item has wrong title.");
            Assert.AreEqual <string>(oneColumnGridControl.LayoutTemplatePath, oneColumnGridToolboxItem.LayoutTemplate, "The grid control toolbox item has layout template path.");
        }
        public void AddLayoutControl_ExistingToolboxSection_VerifyControlIsProperlyAddedToTheToolbox()
        {
            // Arrange: Initialize the GridWidgetRegistrator, ToolboxesConfig and add a PageLayouts section, create a layouts section, create a dummy grid controls
            var initializer      = new DummyGridWidgetRegistrator();
            var fakeTemplatePath = "~/GridSystem/Templates/grid1.html";
            var dummyData        = initializer.PublicCreateGridControlsData(fakeTemplatePath);
            var toolboxesConfig  = new DummyToolboxesConfig();
            var pageControlsMock = new Toolbox(toolboxesConfig.Toolboxes);

            pageControlsMock.Name = "PageLayouts";
            toolboxesConfig.Toolboxes.Add("PageLayouts", pageControlsMock);
            var htmlLayoutsSection = initializer.PublicCreateToolBoxSection(toolboxesConfig, "BootstrapGrids", "BootstrapGridWidgets");
            ConfigElementList <ToolboxItem> parentToolboxItem = htmlLayoutsSection.Tools;

            // Act: add the grid controls to the toolbox
            initializer.PublicAddGridControl(parentToolboxItem, dummyData);

            // Assert: Verify the newly created controls are properly created
            Assert.AreEqual(1, parentToolboxItem.Count, "The grid controls were added to the toolbox.");

            var oneColumnGridToolboxItem = parentToolboxItem.Where <ToolboxItem>(toolboxItem => toolboxItem.Name == dummyData.Name).FirstOrDefault();

            Assert.IsNotNull(oneColumnGridToolboxItem, "The grid control was not added to the toolbox.");
            Assert.AreEqual(dummyData.Title, oneColumnGridToolboxItem.Title, "The grid control toolbox item has wrong title.");
            Assert.AreEqual(dummyData.LayoutTemplatePath, oneColumnGridToolboxItem.LayoutTemplate, "The grid control toolbox item has layout template path.");
        }
Beispiel #3
0
        public void DummyGridSystemInitializer_CreateFakeToolboxSection_VerifySectionIsAddedAndHasProperData()
        {
            //Arrange: Initialize the GridSystemInitializer, ToolboxesConfig and add a PageLayouts section
            DummyGridSystemInitializer initializer = new DummyGridSystemInitializer();
            var toolboxesConfig  = new DummyToolboxesConfig();
            var pageControlsMock = new Toolbox(toolboxesConfig.Toolboxes);

            pageControlsMock.Name = "PageLayouts";
            toolboxesConfig.Toolboxes.Add("PageLayouts", pageControlsMock);

            //Act: create a new toolbox section for the layout controls
            var htmlLayoutsSection = initializer.PublicCreateToolBoxSection(toolboxesConfig);

            //Assert: Verify the newly created section exists and has proper name and title
            Assert.IsNotNull(htmlLayoutsSection, "The toolbox section was not properly created.");
            Assert.AreEqual <string>("HtmlLayouts", htmlLayoutsSection.Name, "The toolbox section has unexpected name.");
            Assert.AreEqual <string>("Bootstrap grid widgets", htmlLayoutsSection.Title, "The toolbox section has unexpected title.");
        }