public void StyleSheetManager_should_return_the_same_instace()
        {
            StyleSheetRegistrarBuilder sm1 = _factory.StyleSheetRegistrar();
            StyleSheetRegistrarBuilder sm2 = _factory.StyleSheetRegistrar();

            Assert.Same(sm1, sm2);
        }
示例#2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="htmlHelper">The current Mvc HtmlHelper context.</param>
        /// <param name="clientSideObjectWriterFactory"></param>
        /// <param name="styleSheetRegistrar"></param>
        /// <param name="scriptRegistrar"></param>
        public ComponentFactory(
            HtmlHelper htmlHelper,
            IClientSideObjectWriterFactory clientSideObjectWriterFactory,
            StyleSheetRegistrarBuilder styleSheetRegistrar,
            ScriptRegistrarBuilder scriptRegistrar)
        {
            // If the instance object is null.
            if (htmlHelper == null)
            {
                throw new System.ArgumentNullException("htmlHelper");
            }
            if (clientSideObjectWriterFactory == null)
            {
                throw new System.ArgumentNullException("clientSideObjectWriterFactory");
            }
            if (styleSheetRegistrar == null)
            {
                throw new System.ArgumentNullException("styleSheetRegistrar");
            }
            if (scriptRegistrar == null)
            {
                throw new System.ArgumentNullException("scriptRegistrar");
            }

            HtmlHelper = htmlHelper;
            ClientSideObjectWriterFactory = clientSideObjectWriterFactory;

            _styleSheetRegistrarBuilder = styleSheetRegistrar;
            _scriptRegistrarBuilder     = scriptRegistrar;
        }
        public StyleSheetRegistrarBuilderTests()
        {
            ViewContext viewContext = new ViewContext
                                          {
                                              HttpContext = TestHelper.CreateMockedHttpContext().Object,
                                              ViewData = new ViewDataDictionary()
                                          };

            _styleSheetRegistrar = new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, new Mock<IWebAssetCollectionResolver>().Object);

            _builder = new StyleSheetRegistrarBuilder(_styleSheetRegistrar);
        }
        public StyleSheetRegistrarBuilderTests()
        {
            ViewContext viewContext = new ViewContext
            {
                HttpContext = TestHelper.CreateMockedHttpContext().Object,
                ViewData    = new ViewDataDictionary()
            };

            _styleSheetRegistrar = new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, new Mock <IWebAssetCollectionResolver>().Object);

            _builder = new StyleSheetRegistrarBuilder(_styleSheetRegistrar);
        }
        public ViewComponentFactoryTests()
        {
            ViewContext viewContext = new ViewContext
                                          {
                                              HttpContext = TestHelper.CreateMockedHttpContext().Object,
                                              ViewData = new ViewDataDictionary()
                                          };

            StyleSheetRegistrar styleSheetRegistrar = new StyleSheetRegistrar(new WebAssetItemCollection(WebAssetDefaultSettings.StyleSheetFilesPath), new List<IStyleableComponent>(), viewContext, new Mock<IWebAssetItemMerger>().Object);
            StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new StyleSheetRegistrarBuilder(styleSheetRegistrar);

            ScriptRegistrar scriptRegistrar = new ScriptRegistrar(new WebAssetItemCollection(WebAssetDefaultSettings.ScriptFilesPath), new List<IScriptableComponent>(), viewContext, new Mock<IWebAssetItemMerger>().Object, new Mock<ScriptWrapperBase>().Object);
            ScriptRegistrarBuilder scriptRegistrarBuilder = new ScriptRegistrarBuilder(scriptRegistrar);

            _factory = new ViewComponentFactory(styleSheetRegistrarBuilder, scriptRegistrarBuilder);
        }
        public ViewComponentFactoryTests()
        {
            ViewContext viewContext = new ViewContext
            {
                HttpContext = TestHelper.CreateMockedHttpContext().Object,
                ViewData    = new ViewDataDictionary()
            };

            StyleSheetRegistrar        styleSheetRegistrar        = new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, new Mock <IWebAssetCollectionResolver>().Object);
            StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new StyleSheetRegistrarBuilder(styleSheetRegistrar);

            ScriptRegistrar        scriptRegistrar        = new ScriptRegistrar(new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath), new List <IScriptableComponent>(), viewContext, new Mock <IWebAssetCollectionResolver>().Object, new Mock <ScriptWrapperBase>().Object);
            ScriptRegistrarBuilder scriptRegistrarBuilder = new ScriptRegistrarBuilder(scriptRegistrar);

            htmlHelper = TestHelper.CreateHtmlHelper();
            _factory   = new ViewComponentFactory(htmlHelper, new Mock <IClientSideObjectWriterFactory>().Object, styleSheetRegistrarBuilder, scriptRegistrarBuilder);
        }
        public ViewComponentModelFactoryTests()
        {
            ViewContext viewContext = new ViewContext
            {
                HttpContext = TestHelper.CreateMockedHttpContext().Object,
                ViewData    = new ViewDataDictionary()
            };

            StyleSheetRegistrar        styleSheetRegistrar        = new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, new Mock <IWebAssetCollectionResolver>().Object);
            StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new StyleSheetRegistrarBuilder(styleSheetRegistrar);

            ScriptRegistrar        scriptRegistrar        = new ScriptRegistrar(new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath), new List <IScriptableComponent>(), viewContext, new Mock <IWebAssetCollectionResolver>().Object, new Mock <ScriptWrapperBase>().Object);
            ScriptRegistrarBuilder scriptRegistrarBuilder = new ScriptRegistrarBuilder(scriptRegistrar);

            htmlHelper = TestHelper.CreateHtmlHelper <TestModel>();

            htmlHelper.ViewData.Model = new TestModel {
                ID = 1, DoubleProperty = 1.0, DecimalProperty = 1.0m, DateTimeProperty = DateTime.Today, TimeProperty = DateTime.Now.TimeOfDay, ComplexModel = new TestModel()
            };

            factory = new ViewComponentFactory <TestModel>(htmlHelper, new Mock <IClientSideObjectWriterFactory>().Object, styleSheetRegistrarBuilder, scriptRegistrarBuilder);
        }
        public ViewComponentModelFactoryTests()
        {
            ViewContext viewContext = new ViewContext
                                          {
                                              HttpContext = TestHelper.CreateMockedHttpContext().Object,
                                              ViewData = new ViewDataDictionary()
                                          };

            StyleSheetRegistrar styleSheetRegistrar = new StyleSheetRegistrar(new WebAssetCollection(WebAssetDefaultSettings.StyleSheetFilesPath), viewContext, new Mock<IWebAssetCollectionResolver>().Object);
            StyleSheetRegistrarBuilder styleSheetRegistrarBuilder = new StyleSheetRegistrarBuilder(styleSheetRegistrar);

            ScriptRegistrar scriptRegistrar = new ScriptRegistrar(new WebAssetCollection(WebAssetDefaultSettings.ScriptFilesPath), new List<IScriptableComponent>(), viewContext, new Mock<IWebAssetCollectionResolver>().Object, new Mock<ScriptWrapperBase>().Object);
            ScriptRegistrarBuilder scriptRegistrarBuilder = new ScriptRegistrarBuilder(scriptRegistrar);

            htmlHelper = TestHelper.CreateHtmlHelper<TestModel>();

            htmlHelper.ViewData.Model = new TestModel { ID = 1, DoubleProperty = 1.0, DecimalProperty = 1.0m, DateTimeProperty = DateTime.Today, TimeProperty = DateTime.Now.TimeOfDay, ComplexModel = new TestModel() };

            factory = new ViewComponentFactory<TestModel>(htmlHelper, new Mock<IClientSideObjectWriterFactory>().Object, styleSheetRegistrarBuilder, scriptRegistrarBuilder);
        }