diff --git a/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs b/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs index d42b40e644..05cf2c9ceb 100644 --- a/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs +++ b/src/Microsoft.AspNet.Hosting.Abstractions/HostingEnvironmentExtensions.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNet.Hosting } if (string.IsNullOrEmpty(hostingEnvironment.WebRootPath)) { - throw new InvalidOperationException("Can not map path because webroot path is not set"); + throw new InvalidOperationException("Cannot map path because webroot path is not set"); } if (virtualPath == null) { diff --git a/test/Microsoft.AspNet.Hosting.Tests/HostingEnvironmentExtensionsTests.cs b/test/Microsoft.AspNet.Hosting.Tests/HostingEnvironmentExtensionsTests.cs index 44ab8996e2..727130ded8 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/HostingEnvironmentExtensionsTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/HostingEnvironmentExtensionsTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.IO; using Microsoft.AspNet.FileProviders; using Microsoft.AspNet.Hosting; @@ -67,5 +68,15 @@ namespace Microsoft.AspNet.Hosting.Tests Assert.Equal("NewName", env.EnvironmentName); } + [Fact] + public void MapPathThrowsWithNoWwwroot() + { + var env = new HostingEnvironment(); + + env.Initialize(".", new WebHostOptions(), null); + + Assert.Throws(() => env.MapPath("file.txt")); + } + } } diff --git a/test/Microsoft.AspNet.Hosting.Tests/testroot/wwwroot/README b/test/Microsoft.AspNet.Hosting.Tests/testroot/wwwroot/README index 4b906ff4a8..d3415c9f70 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/testroot/wwwroot/README +++ b/test/Microsoft.AspNet.Hosting.Tests/testroot/wwwroot/README @@ -1 +1 @@ -This file is here to keep directories needed by tests. Do no remove it. \ No newline at end of file +This file is here to keep directories needed by tests. Do not remove it. \ No newline at end of file