Permalink
Browse files

BundleManifests should be equal even when their assets are in differe…

…nt orders i.e. when one bundle has been sorted. For #142
  • Loading branch information...
1 parent cb6f823 commit 8f2273368b819433a61f32748b71ea546d537bd7 @andrewdavey andrewdavey committed Feb 1, 2012
Showing with 26 additions and 2 deletions.
  1. +25 −1 src/Cassette.UnitTests/Manifests/BundleManifest.cs
  2. +1 −1 src/Cassette/Manifests/BundleManifest.cs
@@ -14,7 +14,7 @@ class TestableBundleManifest : BundleManifest
{
protected override Bundle CreateBundleCore()
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
}
@@ -65,6 +65,30 @@ public void BundleManifestsWithSameAssetsAreEqual()
};
manifest1.Equals(manifest2).ShouldBeTrue();
}
+
+ [Fact]
+ public void BundleManifestsAreEqualEvenIfAssetsAreInDifferentOrders()
+ {
+ var manifest1 = new TestableBundleManifest
+ {
+ Path = "~/path",
+ Assets =
+ {
+ new AssetManifest { Path = "~/A" },
+ new AssetManifest { Path = "~/B" }
+ }
+ };
+ var manifest2 = new TestableBundleManifest
+ {
+ Path = "~/path",
+ Assets =
+ {
+ new AssetManifest { Path = "~/B" },
+ new AssetManifest { Path = "~/A" }
+ }
+ };
+ manifest1.Equals(manifest2).ShouldBeTrue();
+ }
}
public class BundleManifest_CreateBundle_Tests
@@ -72,7 +72,7 @@ public override bool Equals(object obj)
bool AssetsEqual(IEnumerable<AssetManifest> assets)
{
- return Assets.SequenceEqual(assets);
+ return Assets.OrderBy(a => a.Path).SequenceEqual(assets.OrderBy(a => a.Path));
}
public override int GetHashCode()

0 comments on commit 8f22733

Please sign in to comment.