Single-File Bundler: Add a FileSize test (#35149)
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Mon, 20 Apr 2020 15:29:38 +0000 (08:29 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2020 15:29:38 +0000 (08:29 -0700)
Add a bundler consistency tests that verifies that the size of each embedded file
(recorded in the bundle manifest) matches its original size of the file on disk.

src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundlerConsistencyTests.cs

index 2e0bda9e45ed32d7682f4a78e693d3a8aab262c1..00f3b1cc843c26ce85d2dd3b42a9397a76563955 100644 (file)
@@ -143,6 +143,17 @@ namespace Microsoft.NET.HostModel.Tests
             bundler.BundleManifest.Contains($"{coreclr}").Should().Be(options.HasFlag(BundleOptions.BundleNativeBinaries));
         }
 
+        [Fact]
+        public void TestFileSizes()
+        {
+            var fixture = sharedTestState.TestFixture.Copy();
+            var bundler = BundleHelper.Bundle(fixture);
+            var publishPath = BundleHelper.GetPublishPath(fixture);
+
+            bundler.BundleManifest.Files.ForEach(file =>
+                Assert.True(file.Size == new FileInfo(Path.Combine(publishPath, file.RelativePath)).Length));
+        }
+
         [Fact]
         public void TestAssemblyAlignment()
         {