GetControlTypesInBundles() public method

public GetControlTypesInBundles ( string bundles, string fileName ) : List
bundles string
fileName string
return List
Ejemplo n.º 1
0
        static IEnumerable <EmbeddedScript> GetEmbeddedScripts(params string[] toolkitBundles)
        {
            var result = new List <EmbeddedScript>();

            var toolkitAssembly = typeof(ToolkitResourceManager).Assembly;

            result.AddRange(new Localization().GetAllLocalizationEmbeddedScripts());

            var trace          = new HashSet <string>();
            var bundleResolver = new Bundling.BundleResolver(new Bundling.DefaultCache());

            foreach (var type in bundleResolver.GetControlTypesInBundles(toolkitBundles, GetConfigPath()))
            {
                foreach (var name in GetScriptEntries(type).Select(entry => entry.ResourceName))
                {
                    if (trace.Contains(name))
                    {
                        continue;
                    }

                    result.Add(new EmbeddedScript(name, type.Assembly));
                    trace.Add(name);
                }
            }

            return(result);
        }
        public void Caching_SetMethodIsNotCalledIfCacheIsFull()
        {
            _moqCache.Setup(c => c.Get<string>(CacheConfigName)).Returns(File.ReadAllText(TestConfigPath));

            var resolver = new BundleResolver(_moqCache.Object);
            resolver.GetControlTypesInBundles(null, TestConfigPath);
            _moqCache.Verify(c => c.Set(CacheConfigName, It.IsAny<string>(), It.IsAny<string>()), Times.Never());
        }
        public void Caching_SetMethodIsCalledIfCacheIsEmpty()
        {
            _moqCache.Setup(c => c.Get<string>(CacheConfigName)).Returns("");

            var resolver = new BundleResolver(_moqCache.Object);
            resolver.GetControlTypesInBundles(new[] { "SingleBundle" }, TestConfigPath);
            _moqCache.Verify(c => c.Set(CacheConfigName, It.IsAny<string>(), It.IsAny<string>()), Times.Once());
        }
        public void MultipleControlsInBundleTest()
        {
            var resolver = new BundleResolver(_moqCache.Object);
            var results = resolver.GetControlTypesInBundles(new[] { "MultiBundle" }, TestConfigPath);

            // Assert all controls in MultiBundle group
            AssertResults(results, new[] {
                "TextBoxWatermarkExtender",
                "RoundedCornersExtender",
                "DropShadowExtender"
            });
        }
        public void SingleControlInBundleTest()
        {
            var resolver = new BundleResolver(_moqCache.Object);
            var results = resolver.GetControlTypesInBundles(new[] { "SingleBundle" }, TestConfigPath);

            // Assert all controls in SingleBundle group
            AssertResults(results, new[] { "TextBoxWatermarkExtender" });
        }
 public void CustomBundleWithoutConfigFileShouldErrorTest()
 {
     var resolver = new BundleResolver(_moqCache.Object);
     Assert.Throws<Exception>(() => resolver.GetControlTypesInBundles(new[] { "Accordion" }, "nonexistantfile"), "AjaxControlToolkit.config file is not defined");
 }
        public void WithoutConfigShouldReturnsAllActControlsTest()
        {
            var resolver = new BundleResolver(_moqCache.Object);
            var results = resolver.GetControlTypesInBundles(null, "nonexistantfile");

            var bundleTypes = new List<Type>();
            foreach(var bundleControl in ControlDependencyMap.Maps.Values) {
                bundleTypes.AddRange(bundleControl.Dependecies);
            }

            Assert.AreEqual(results.Count, bundleTypes.Distinct().Count());
            foreach(var type in bundleTypes) {
                Assert.IsTrue(results.Contains(type), "Can't resolve {0}", type);
            }
        }