コード例 #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 ReadShimWithExports()
        {
            var config = ReadJson(new TestFileReader());
            var shim   = new ShimEntry
            {
                For          = "jquery-validate",
                Dependencies =
                    new List <RequireDependency>
                {
                    new RequireDependency {
                        Dependency = "jquery"
                    }
                },
                Exports = "jqVal"
            };
            var expected = ConfigurationCreators.CreateCollectionWithShims(shim);

            CustomAssert.JsonEquals(expected, config);
        }
コード例 #3
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);
        }