public void StoresReferences() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("~\\test"); bundle.AddReference("~\\other"); bundle.References.SequenceEqual(new[] { "~/test", "~/other" }).ShouldBeTrue(); }
public void StoresReferences() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("~\\test"); bundle.AddReference("~\\other"); bundle.References.SequenceEqual(new[] { "~/test", "~/other" }).ShouldBeTrue(); }
public void GivenBundlesWithOnePageLocationAssigned_WhenReferenceCallOmitsPageLocation_ThenGetBundlesHonoursTheOriginalPageLocation() { var jquery = new TestableBundle("~/jquery") { PageLocation = "head" }; var app = new TestableBundle("~/app"); app.AddReference("~/jquery"); var findResultQueue = new Queue <IEnumerable <Bundle> >(new[] { new Bundle[] { jquery }, new Bundle[] { app } }); bundleContainer.Setup(c => c.FindBundlesContainingPath(It.IsAny <string>())) .Returns <string>(s => findResultQueue.Dequeue()); var queue = new Queue <IEnumerable <Bundle> >(); queue.Enqueue(new[] { jquery }); queue.Enqueue(new[] { jquery, app }); bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny <IEnumerable <Bundle> >())) .Returns <IEnumerable <Bundle> >(ms => queue.Dequeue()); builder.Reference("~/jquery"); builder.Reference("~/app"); builder.GetBundles("head").Single().ShouldBeSameAs(jquery); builder.GetBundles(null).Single().ShouldBeSameAs(app); }
public void ReferenceStartingWithSlashIsConvertedToAppRelative() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("/test"); bundle.References.Single().ShouldEqual("~/test"); }
public void BundleRelativePathIsConvertedToAppRelative() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("../lib"); bundle.References.Single().ShouldEqual("~/lib"); }
public void TrailingSlashIsRemoved() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("../lib/"); bundle.References.Single().ShouldEqual("~/lib"); }
public void UrlIsNotConverted() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("http://test.com/"); bundle.References.Single().ShouldEqual("http://test.com/"); }
public BundleSerializer_Tests() { bundle = new TestableBundle("~") { Hash = new byte[] { 1, 2, 3 }, ContentType = "content-type", PageLocation = "page-location", Assets = { new StubAsset("~/asset", "asset-content") { ReferenceList = { new AssetReference("~/asset", "~/raw-file/reference", -1, AssetReferenceType.RawFilename) } } }, HtmlAttributes = { { "attribute", "value" } } }; bundle.AddReference("~/bundle-reference"); SerializeToElement(); }
public void GivenBundleWithReferenceToAnotherBundle_BundlesAreSortedInDependencyOrder() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); var container = new BundleContainer(new[] { bundle1, bundle2 }); var sorted = container.IncludeReferencesAndSortBundles(new[] { bundle1, bundle2 }); sorted.SequenceEqual(new[] { bundle2, bundle1 }).ShouldBeTrue(); }
public void GivenBundleWithReferenceToAnotherBundle_BundlesAreSortedInDependencyOrder() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); var collection = CreateBundleCollection(new[] { bundle1, bundle2 }); collection.BuildReferences(); var sorted = collection.SortBundles(new[] { bundle1, bundle2 }); sorted.SequenceEqual(new[] { bundle2, bundle1 }).ShouldBeTrue(); }
public void GivenBundleWithReferenceToAnotherBundle_BundlesAreSortedInDependencyOrder() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); var collection = CreateBundleCollection(new[] { bundle1, bundle2 }); collection.BuildReferences(); var sorted = collection.SortBundles(new[] { bundle1, bundle2 }); sorted.SequenceEqual(new[] { bundle2, bundle1 }).ShouldBeTrue(); }
public void GivenBundlesWithCyclicReferences_WhenBuildReferences_ThenExceptionThrown() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); bundle2.AddReference("~/bundle1"); var collection = CreateBundleCollection(new[] { bundle1, bundle2 }); Assert.Throws<InvalidOperationException>( () => collection.BuildReferences() ); }
public void GivenBundleWithReferenceToAnotherBundle_BundlesAreSortedInDependencyOrder() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); var container = new BundleContainer(new[] { bundle1, bundle2 }); var sorted = container.IncludeReferencesAndSortBundles(new[] { bundle1, bundle2 }); sorted.SequenceEqual(new[] { bundle2, bundle1 }).ShouldBeTrue(); }
public void GivenBundlesWithCyclicReferences_WhenBuildReferences_ThenExceptionThrown() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); bundle2.AddReference("~/bundle1"); var collection = CreateBundleCollection(new[] { bundle1, bundle2 }); Assert.Throws<InvalidOperationException>( () => collection.BuildReferences() ); }
public void GivenBundlesWithCyclicReferences_WhenIncludeReferencesAndSortBundles_ThenExceptionThrown() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); bundle2.AddReference("~/bundle1"); var container = new BundleContainer(new[] { bundle1, bundle2 }); Assert.Throws<InvalidOperationException>(delegate { container.IncludeReferencesAndSortBundles(new[] { bundle2, bundle1 }); }); }
public void GivenBundleReferencedInOneLocationAlsoUsedInAnother_WhenGetBundlesForSecondLocation_ThenBundleForFirstLocationIsNotIncluded() { var bundle1 = new TestableBundle("~/test1") { PageLocation = "head" }; var bundle2 = new TestableBundle("~/test2"); bundle2.AddReference("~/test1"); bundleContainer.Setup(c => c.FindBundlesContainingPath("~/test2")) .Returns(new Bundle[] { bundle2 }); bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny<IEnumerable<Bundle>>())) .Returns<IEnumerable<Bundle>>(ms => new[] { bundle1, bundle2 }); builder.Reference("~/test2"); builder.GetBundles(null).Count().ShouldEqual(1); }
public void GivenBundleWithInvalid_ConstructorThrowsException() { var bundle1 = new TestableBundle("~/bundle1"); bundle1.AddReference("~\\bundle2"); var exception = Assert.Throws <AssetReferenceException>(delegate { new BundleContainer(new[] { bundle1 }); }); exception.Message.ShouldEqual("Reference error in bundle descriptor for \"~/bundle1\". Cannot find \"~/bundle2\"."); }
public void GivenBundlesWithNoPageLocationAssigned_WhenReferenceCallAssignsPageLocation_ThenGetBundlesHonoursTheNewAsignment() { var jquery = new TestableBundle("~/jquery"); var app = new TestableBundle("~/app"); app.AddReference("~/jquery"); AddBundles(jquery, app); builder.Reference("~/jquery", "head"); builder.Reference("~/app"); builder.GetBundles("head").Single().ShouldBeSameAs(jquery); builder.GetBundles(null).Single().ShouldBeSameAs(app); }
public void GivenBundlesWithCyclicReferences_WhenIncludeReferencesAndSortBundles_ThenExceptionThrown() { var bundle1 = new TestableBundle("~/bundle1"); var bundle2 = new TestableBundle("~/bundle2"); bundle1.AddReference("~/bundle2"); bundle2.AddReference("~/bundle1"); var container = new BundleContainer(new[] { bundle1, bundle2 }); Assert.Throws <InvalidOperationException>(delegate { container.IncludeReferencesAndSortBundles(new[] { bundle2, bundle1 }); }); }
public void WhenSortBundlesWithCycle_ThenExceptionThrownHasMessageWithCycleBundlePaths() { var bundleA = new TestableBundle("~/a"); var bundleB = new TestableBundle("~/b"); bundleA.AddReference("~/b"); bundleB.AddReference("~/a"); var collection = CreateBundleCollection(new[] { bundleA, bundleB }); var exception = Assert.Throws<InvalidOperationException>( () => collection.BuildReferences() ); exception.Message.ShouldContain("~/a"); exception.Message.ShouldContain("~/b"); }
public void GivenBundleReferencedInOneLocationAlsoUsedInAnotherAndPageLocationIsOverridden_WhenGetBundlesForSecondLocation_ThenBundleForFirstLocationIsNotIncluded() { var bundle1 = new TestableBundle("~/test1") { PageLocation = "head" }; var bundle2 = new TestableBundle("~/test2"); bundle2.AddReference("~/test1"); AddBundles(bundle1, bundle2); builder.Reference("~/test2", "LOCATION"); builder.GetBundles("LOCATION").Count().ShouldEqual(1); }
public void GivenBundleWithInvalid_BuildReferencesThrowsException() { var bundle1 = new TestableBundle("~/bundle1"); bundle1.AddReference("~\\bundle2"); collection.Add(bundle1); var exception = Assert.Throws <AssetReferenceException>(delegate { collection.BuildReferences(); }); exception.Message.ShouldEqual("Reference error in bundle descriptor for \"~/bundle1\". Cannot find \"~/bundle2\"."); }
public void GivenBundlesWithOnePageLocationAssigned_WhenReferenceCallOmitsPageLocation_ThenGetBundlesHonoursTheOriginalPageLocation() { var jquery = new TestableBundle("~/jquery") { PageLocation = "head" }; var app = new TestableBundle("~/app"); app.AddReference("~/jquery"); AddBundles(jquery, app); builder.Reference("~/jquery"); builder.Reference("~/app"); builder.GetBundles("head").Single().ShouldBeSameAs(jquery); builder.GetBundles(null).Single().ShouldBeSameAs(app); }
public void GivenBundleReferencedInOneLocationAlsoUsedInAnotherAndPageLocationIsOverridden_WhenGetBundlesForSecondLocation_ThenBundleForFirstLocationIsNotIncluded() { var bundle1 = new TestableBundle("~/test1") { PageLocation = "head" }; var bundle2 = new TestableBundle("~/test2"); bundle2.AddReference("~/test1"); bundleContainer.Setup(c => c.FindBundlesContainingPath("~/test2")) .Returns(new Bundle[] { bundle2 }); bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny <IEnumerable <Bundle> >())) .Returns <IEnumerable <Bundle> >(ms => new[] { bundle1, bundle2 }); builder.Reference("~/test2", "LOCATION"); builder.GetBundles("LOCATION").Count().ShouldEqual(1); }
public void WhenInterdependenciesBetweenBundlesOfDifferentType_DoesNotDuplicateBundles() { var bundleA = new ScriptBundle("~/a"); var bundleB = new StylesheetBundle("~/b"); var bundleC = new TestableBundle("~/c"); bundleC.AddReference("~/a"); var bundles = new Bundle[] { bundleA, bundleB, bundleC }; var collection = CreateBundleCollection(bundles); collection.BuildReferences(); var sorted = collection.SortBundles(bundles).ToArray(); sorted.ShouldEqual(new Bundle[] { bundleB, bundleA, bundleC }); }
public void ThreeBundlesWithDifferentPageLocationsInDependencyChainGetReferencedByOneReferenceCall() { var a = new TestableBundle("~/a") { PageLocation = "a" }; var b = new TestableBundle("~/b") { PageLocation = "b" }; var c = new TestableBundle("~/c"); c.AddReference("~/b"); b.AddReference("~/a"); AddBundles(a, b, c); builder.Reference("~/c"); builder.GetBundles(null).Single().ShouldBeSameAs(c); builder.GetBundles("a").Single().ShouldBeSameAs(a); builder.GetBundles("b").Single().ShouldBeSameAs(b); }
public void WhenInterdependenciesBetweenBundlesOfDifferentType_DoesNotDuplicateBundles() { var bundleA = new ScriptBundle("~/a"); var bundleB = new StylesheetBundle("~/b"); var bundleC = new TestableBundle("~/c"); bundleC.AddReference("~/a"); var bundles = new Bundle[] { bundleA, bundleB, bundleC }; var collection = CreateBundleCollection(bundles); collection.BuildReferences(); var sorted = collection.SortBundles(bundles).ToArray(); sorted.ShouldEqual(new Bundle[] { bundleB, bundleA, bundleC }); }
public void UrlIsNotConverted() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("http://test.com/"); bundle.References.Single().ShouldEqual("http://test.com/"); }
public void TrailingSlashIsRemoved() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("../lib/"); bundle.References.Single().ShouldEqual("~/lib"); }
public void ReferenceStartingWithSlashIsConvertedToAppRelative() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("/test"); bundle.References.Single().ShouldEqual("~/test"); }
public void BundleRelativePathIsConvertedToAppRelative() { var bundle = new TestableBundle("~/bundle"); bundle.AddReference("../lib"); bundle.References.Single().ShouldEqual("~/lib"); }
public void GivenBundleWithInvalid_BuildReferencesThrowsException() { var bundle1 = new TestableBundle("~/bundle1"); bundle1.AddReference("~\\bundle2"); collection.Add(bundle1); var exception = Assert.Throws<AssetReferenceException>(delegate { collection.BuildReferences(); }); exception.Message.ShouldEqual("Reference error in bundle descriptor for \"~/bundle1\". Cannot find \"~/bundle2\"."); }
public void GivenBundlesWithNoPageLocationAssigned_WhenReferenceCallAssignsPageLocation_ThenGetBundlesHonoursTheNewAsignment() { var jquery = new TestableBundle("~/jquery"); var app = new TestableBundle("~/app"); app.AddReference("~/jquery"); var findResultQueue = new Queue<IEnumerable<Bundle>>(new[] { new Bundle[] { jquery }, new Bundle[] { app } }); bundleContainer.Setup(c => c.FindBundlesContainingPath(It.IsAny<string>())) .Returns<string>(s => findResultQueue.Dequeue()); var queue = new Queue<IEnumerable<Bundle>>(); queue.Enqueue(new[] { jquery }); queue.Enqueue(new[] { jquery, app }); bundleContainer.Setup(c => c.IncludeReferencesAndSortBundles(It.IsAny<IEnumerable<Bundle>>())) .Returns<IEnumerable<Bundle>>(ms => queue.Dequeue()); builder.Reference("~/jquery", "head"); builder.Reference("~/app"); builder.GetBundles("head").Single().ShouldBeSameAs(jquery); builder.GetBundles(null).Single().ShouldBeSameAs(app); }
public void GivenBundleWithInvalid_ConstructorThrowsException() { var bundle1 = new TestableBundle("~/bundle1"); bundle1.AddReference("~\\bundle2"); var exception = Assert.Throws<AssetReferenceException>(delegate { new BundleContainer(new[] {bundle1}); }); exception.Message.ShouldEqual("Reference error in bundle descriptor for \"~/bundle1\". Cannot find \"~/bundle2\"."); }
public void WhenSortBundlesWithCycle_ThenExceptionThrownHasMessageWithCycleBundlePaths() { var bundleA = new TestableBundle("~/a"); var bundleB = new TestableBundle("~/b"); bundleA.AddReference("~/b"); bundleB.AddReference("~/a"); var container = new BundleContainer(new[] { bundleA, bundleB }); var exception = Assert.Throws<InvalidOperationException>( () => container.IncludeReferencesAndSortBundles(new[] { bundleA, bundleB }) ); exception.Message.ShouldContain("~/a"); exception.Message.ShouldContain("~/b"); }