Пример #1
0
        public void GetViewScriptFileName_ViewNameWithDot_ConstructScriptName()
        {
            // Arrange
            var dummyModel = new DummyDesignerModel();
            var viewName = "Property.Grid";

            // Act
            string scriptName = dummyModel.GetViewScriptFileNamePublic(viewName);

            // Assert
            Assert.AreEqual("designerview-property-grid.js", scriptName, "The script name is not constructed correctly.");
        }
Пример #2
0
        public void ExtractViewName_FullFileName_ExtractsViewName()
        {
            // Arrange
            var dummyModel = new DummyDesignerModel();
            string fileName = "DesignerView.Property.Grid.cshtml";

            // Act
            string viewName = dummyModel.ExtractViewNamePublic(fileName);

            // Assert
            Assert.AreEqual("Property.Grid", viewName, "The viewName is not extracted correctly.");
        }
Пример #3
0
        public void IsDesignerView_DesignerPrefix_ReturnsTrue()
        {
            // Arrange
            var dummyModel = new DummyDesignerModel();
            var fileName = "DesignerView.someViewName";

            // Act
            var isDesignerView = dummyModel.IsDesignerViewPublic(fileName);

            // Assert
            Assert.IsTrue(isDesignerView, "The fileName is not recognized as valid designer view");
        }
Пример #4
0
        public void PopulateScriptReferences_ViewsCollection_ConstructScriptReferencesCollection()
        {
            // TODO: Reduce class coupling
            // Arrange
            string widgetName = "Dummy";
            var views = new List<string>();
            views.Add("DesignerView.someViewName");
            var designerViewConfigs = this.CreateDummyDesignerViewConfigModel();

            using (var objFactory = new ObjectFactoryContainerRegion())
            {
                ObjectFactory.Container.RegisterType<ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name));
                ObjectFactory.Container.RegisterType<XmlConfigProvider, DummyConfigProvider>();
                Config.RegisterSection<VirtualPathSettingsConfig>();
                Config.RegisterSection<ControlsConfig>();
                Config.RegisterSection<ResourcesConfig>();

                using (var factoryReg = new ControllerFactoryRegion<DummyControllerFactory>())
                {
                    factoryReg.Factory.ControllerRegistry["Dummy"] = typeof(DummyController);
                    factoryReg.Factory.ControllerRegistry["Designer"] = typeof(DesignerController);

                    var fileResolverPrefix = "~/Frontend-Assembly";
                    VirtualPathManager.AddVirtualFileResolver<DummyVirtualFileResolver>(fileResolverPrefix + "*", "DummyVirtualFileResolver");

                    var dummyModel = new DummyDesignerModel(views, new List<string>(), widgetName, "someViewName");

                    try
                    {
                        // Act
                        dummyModel.PopulateScriptReferencesPublic(widgetName, designerViewConfigs);
                    }
                    finally
                    {
                        VirtualPathManager.RemoveVirtualFileResolver(fileResolverPrefix);
                        VirtualPathManager.Reset();
                    }

                    // Assert
                    Assert.AreEqual(4, dummyModel.ScriptReferences.Count(), "The script count is not as expected.");
                    Assert.IsTrue(dummyModel.ScriptReferences.Contains("Mvc/Scripts/Dummy/designerview-someviewname.js"), "ScriptReferences doesn't contain scripts for the view.");
                    Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script1), "ScriptReferences doesn't contain expected scripts.");
                    Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script2), "ScriptReferences doesn't contain expected scripts.");
                    Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script3), "ScriptReferences doesn't contain expected scripts.");
                }
            }
        }
Пример #5
0
        public void PopulateScriptReferences_EmptyViewsCollection_ConstructScriptReferencesCollection()
        {
            // Arrange
            var dummyModel = new DummyDesignerModel();
            var widgetName = "Dummy";
            var designerViewConfigs = this.CreateDummyDesignerViewConfigModel();

            // Act
            dummyModel.PopulateScriptReferencesPublic(widgetName, designerViewConfigs);

            // Assert
            Assert.AreEqual(3, dummyModel.ScriptReferences.Count(), "The script count is not as expected.");
            Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script1), "ScriptReferences doesn't contain expected scripts.");
            Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script2), "ScriptReferences doesn't contain expected scripts.");
            Assert.IsTrue(dummyModel.ScriptReferences.Contains(Script3), "ScriptReferences doesn't contain expected scripts.");
        }