コード例 #1
0
        public void MergeShimsWithSameKey()
        {
            var jqueryShim = new ShimEntry
            {
                For          = "jquery",
                Dependencies = new List <RequireDependency>
                {
                    new RequireDependency {
                        Dependency = "depA"
                    },
                    new RequireDependency {
                        Dependency = "depB"
                    }
                }
            };

            var altJqueryShim = new ShimEntry
            {
                For          = "jquery",
                Dependencies = new List <RequireDependency>
                {
                    new RequireDependency {
                        Dependency = "depB"
                    },
                    new RequireDependency {
                        Dependency = "depD"
                    }
                }
            };

            var firstCollection  = ConfigurationCreators.CreateCollectionWithShims(jqueryShim);
            var secondCollection = ConfigurationCreators.CreateCollectionWithShims(altJqueryShim);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expectedShim = new ShimEntry
            {
                For          = "jquery",
                Dependencies = new List <RequireDependency>
                {
                    new RequireDependency {
                        Dependency = "depA"
                    },
                    new RequireDependency {
                        Dependency = "depB"
                    },
                    new RequireDependency {
                        Dependency = "depD"
                    }
                }
            };

            var expected = ConfigurationCreators.CreateCollectionWithShims(expectedShim);

            CustomAssert.JsonEquals(expected, merged);
        }
コード例 #2
0
        public void CreateSingleAutoBundleListForDifferentBundleIds()
        {
            var firstBundle = new AutoBundle
            {
                Id         = "bundleA",
                OutputPath = @"\Scripts\bundleA.js",
                Includes   = new List <AutoBundleItem> {
                    new AutoBundleItem {
                        File = "jquery"
                    }
                },
                Excludes = new List <AutoBundleItem> {
                    new AutoBundleItem {
                        File = "jquery"
                    }
                }
            };
            var secondBundle = new AutoBundle
            {
                Id         = "bundleB",
                OutputPath = @"\Scripts\bundleB.js",
                Includes   = new List <AutoBundleItem> {
                    new AutoBundleItem {
                        File = "jquery"
                    }
                },
                Excludes = new List <AutoBundleItem> {
                    new AutoBundleItem {
                        File = "jquery"
                    }
                }
            };

            var firstCollection  = ConfigurationCreators.CreateCollectionWithAutoBundles(firstBundle);
            var secondCollection = ConfigurationCreators.CreateCollectionWithAutoBundles(secondBundle);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expectedCollection = ConfigurationCreators.CreateEmptyCollection();

            expectedCollection.AutoBundles.Bundles = new List <AutoBundle>
            {
                firstBundle,
                secondBundle
            };

            CustomAssert.JsonEquals(expectedCollection, merged);
        }
コード例 #3
0
        public void OverridePathsWithSameKey()
        {
            var jqueryPath    = new RequirePath("jquery", "jquery-1.06.2");
            var altJqueryPath = new RequirePath("jquery", "jquery-1.05.3");

            var firstCollection  = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath);
            var secondCollection = ConfigurationCreators.CreateCollectionWithPaths(altJqueryPath);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expected = ConfigurationCreators.CreateCollectionWithPaths(altJqueryPath);

            CustomAssert.JsonEquals(expected, merged);
        }
コード例 #4
0
        public void UnitePathsWhenKeysAreDifferent()
        {
            var jqueryPath  = new RequirePath("jquery", "jquery-1.06.2");
            var amplifyPath = new RequirePath("amplify", "amplify-10.3.5");

            var firstCollection  = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath);
            var secondCollection = ConfigurationCreators.CreateCollectionWithPaths(amplifyPath);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expected = ConfigurationCreators.CreateCollectionWithPaths(jqueryPath, amplifyPath);

            CustomAssert.JsonEquals(expected, merged);
        }
コード例 #5
0
        public void UniteMapElementsForSingleScript()
        {
            var firstMap = new RequireMapElement
            {
                For          = "scriptA",
                Replacements = new List <RequireReplacement>
                {
                    new RequireReplacement {
                        OldKey = "jquery", NewKey = "jquery.min"
                    }
                }
            };

            var secondMap = new RequireMapElement
            {
                For          = "scriptA",
                Replacements = new List <RequireReplacement>
                {
                    new RequireReplacement {
                        OldKey = "amplify", NewKey = "amplify.min"
                    }
                }
            };

            var firstCollection  = ConfigurationCreators.CreateCollectionWithMaps(firstMap);
            var secondCollection = ConfigurationCreators.CreateCollectionWithMaps(secondMap);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expectedCollection = ConfigurationCreators.CreateEmptyCollection();

            expectedCollection.Map.MapElements.Add(new RequireMapElement
            {
                For          = "scriptA",
                Replacements = new List <RequireReplacement>
                {
                    new RequireReplacement {
                        OldKey = "jquery", NewKey = "jquery.min"
                    },
                    new RequireReplacement {
                        OldKey = "amplify", NewKey = "amplify.min"
                    }
                }
            });

            CustomAssert.JsonEquals(expectedCollection, merged);
        }
コード例 #6
0
        public void OverrideOutputPathForAutoBundleWithSameId()
        {
            var firstBundle = new AutoBundle
            {
                Id         = "bundleA",
                OutputPath = @"\Scripts\bundleA.js",
                Includes   = new List <AutoBundleItem>(),
                Excludes   = new List <AutoBundleItem>()
            };

            var secondBundle = new AutoBundle
            {
                Id         = "bundleA",
                OutputPath = @"\Scripts\bundleB.js",
                Includes   = new List <AutoBundleItem>(),
                Excludes   = new List <AutoBundleItem>()
            };

            var firstCollection  = ConfigurationCreators.CreateCollectionWithAutoBundles(firstBundle);
            var secondCollection = ConfigurationCreators.CreateCollectionWithAutoBundles(secondBundle);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expectedCollection = ConfigurationCreators.CreateEmptyCollection();

            expectedCollection.AutoBundles.Bundles = new List <AutoBundle>
            {
                new AutoBundle
                {
                    Id         = "bundleA",
                    OutputPath = @"\Scripts\bundleB.js",
                    Includes   = new List <AutoBundleItem>(),
                    Excludes   = new List <AutoBundleItem>()
                }
            };

            CustomAssert.JsonEquals(expectedCollection, merged);
        }
コード例 #7
0
        public void CreateSingleMapListForDifferentScripts()
        {
            var scriptAMap = new RequireMapElement
            {
                For          = "scriptA",
                Replacements = new List <RequireReplacement>
                {
                    new RequireReplacement {
                        OldKey = "jquery", NewKey = "jquery.min"
                    }
                }
            };

            var scriptBMap = new RequireMapElement
            {
                For          = "scriptB",
                Replacements = new List <RequireReplacement>
                {
                    new RequireReplacement {
                        OldKey = "jquery", NewKey = "jquery.custom"
                    }
                }
            };


            var firstCollection  = ConfigurationCreators.CreateCollectionWithMaps(scriptAMap);
            var secondCollection = ConfigurationCreators.CreateCollectionWithMaps(scriptBMap);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            var expectedCollection = ConfigurationCreators.CreateEmptyCollection();

            expectedCollection.Map.MapElements.Add(scriptAMap);
            expectedCollection.Map.MapElements.Add(scriptBMap);

            CustomAssert.JsonEquals(expectedCollection, merged);
        }
コード例 #8
0
        public void OverrideExportsValueForShimsWithSameKey()
        {
            var jqueryShim = new ShimEntry
            {
                For          = "jquery",
                Dependencies = new List <RequireDependency>(),
                Exports      = "jqu"
            };

            var altJqueryShim = new ShimEntry
            {
                For          = "jquery",
                Dependencies = new List <RequireDependency>(),
                Exports      = "jlo"
            };

            var firstCollection  = ConfigurationCreators.CreateCollectionWithShims(jqueryShim);
            var secondCollection = ConfigurationCreators.CreateCollectionWithShims(altJqueryShim);

            var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection);
            var merged = merger.GetMerged();

            Assert.Equal("jlo", merged.Shim.ShimEntries.FirstOrDefault().Exports);
        }