public void Should_be_to_find_group_by_name()
        {
            _collection.AddRange(new[] { new WebAssetGroup("group1", false)
                                         {
                                             DefaultPath = WebAssetDefaultSettings.ScriptFilesPath
                                         }, new WebAssetGroup("group2", false)
                                         {
                                             DefaultPath = WebAssetDefaultSettings.ScriptFilesPath
                                         }, new WebAssetGroup("group3", false)
                                         {
                                             DefaultPath = WebAssetDefaultSettings.ScriptFilesPath
                                         } });

            Assert.NotNull(_collection.FindGroupByName("group2"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new web asset group.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="configureAction">The configure action.</param>
        /// <example>
        /// <code lang="CS">
        /// &lt;%= Html.Telerik().ScriptRegistrar()
        ///            .Scripts(scripts => scripts.AddGroup("Group1", group =>
        ///                 {
        ///                     group.Add("script1.js");
        ///                 }
        ///            ))
        /// %&gt;
        /// </code>
        /// </example>
        public virtual WebAssetCollectionBuilder AddGroup(string name, Action <WebAssetGroupBuilder> configureAction)
        {
            Guard.IsNotNullOrEmpty(name, "name");
            Guard.IsNotNull(configureAction, "configureAction");

            WebAssetGroup itemGroup = assets.FindGroupByName(name);

            if (itemGroup != null)
            {
                throw new ArgumentException(TextResource.GroupWithSpecifiedNameAlreadyExistsPleaseSpecifyADifferentName.FormatWith(name));
            }

            itemGroup = new WebAssetGroup(name, false)
            {
                DefaultPath = assets.DefaultPath
            };
            assets.Add(itemGroup);

            WebAssetGroupBuilder builder = new WebAssetGroupBuilder(itemGroup);

            configureAction(builder);

            return(this);
        }