Example #1
0
        public void UseStaticWebAssetsCore_DoesNothing_WhenManifestDoesNotContainEntries()
        {
            // Arrange
            var manifestContent = @$ "<StaticWebAssets Version=" "1.0" ">
</StaticWebAssets>";

            var manifest     = CreateManifest(manifestContent);
            var originalRoot = new NullFileProvider();
            var environment  = new HostingEnvironment()
            {
                WebRootFileProvider = originalRoot
            };

            // Act
            StaticWebAssetsLoader.UseStaticWebAssetsCore(environment, manifest);

            // Assert
            Assert.Equal(originalRoot, environment.WebRootFileProvider);
        }
Example #2
0
        public void ResolveManifest_ManifestFromFile()
        {
            // Arrange
            var expectedManifest = @"<StaticWebAssets Version=""1.0"">
  <ContentRoot Path=""/Path"" BasePath=""/BasePath"" />
</StaticWebAssets>
";

            var environment = new HostingEnvironment()
            {
                ApplicationName = "Microsoft.AspNetCore.Hosting"
            };

            // Act
            var manifest = StaticWebAssetsLoader.ResolveManifest(environment);

            // Assert
            Assert.Equal(expectedManifest, new StreamReader(manifest).ReadToEnd());
        }
Example #3
0
        public void UseStaticWebAssetsCore_CreatesCompositeRoot_WhenThereAreContentRootsInTheManifest()
        {
            // Arrange
            var manifestContent = @$ "<StaticWebAssets Version=" "1.0" ">
    <ContentRoot Path=" "{AppContext.BaseDirectory}" " BasePath=" "/BasePath" " />
</StaticWebAssets>";

            var manifest     = CreateManifest(manifestContent);
            var originalRoot = new NullFileProvider();
            var environment  = new HostingEnvironment()
            {
                WebRootFileProvider = originalRoot
            };

            // Act
            StaticWebAssetsLoader.UseStaticWebAssetsCore(environment, manifest);

            // Assert
            var composite = Assert.IsType <CompositeFileProvider>(environment.WebRootFileProvider);

            Assert.Equal(2, composite.FileProviders.Count());
            Assert.Equal(originalRoot, composite.FileProviders.First());
        }