Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Renamed PhysicalFileProviderResult and VirtualFileProviderResult to P…
Browse files Browse the repository at this point in the history
…hysicalFileResult and VirtualFileResult respectively
  • Loading branch information
kichalla committed Oct 2, 2015
1 parent 130d94e commit eef6c38
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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;
Expand All @@ -16,18 +16,18 @@ namespace Microsoft.AspNet.Mvc
/// A <see cref="FileResult"/> on execution will write a file from disk to the response
/// using mechanisms provided by the host.
/// </summary>
public class PhysicalFileProviderResult : FileResult
public class PhysicalFileResult : FileResult
{
private const int DefaultBufferSize = 0x1000;
private string _fileName;

/// <summary>
/// Creates a new <see cref="PhysicalFileProviderResult"/> instance with
/// Creates a new <see cref="PhysicalFileResult"/> instance with
/// the provided <paramref name="fileName"/> and the provided <paramref name="contentType"/>.
/// </summary>
/// <param name="fileName">The path to the file. The path must be an absolute path.</param>
/// <param name="contentType">The Content-Type header of the response.</param>
public PhysicalFileProviderResult(string fileName, string contentType)
public PhysicalFileResult(string fileName, string contentType)
: this(fileName, new MediaTypeHeaderValue(contentType))
{
if (fileName == null)
Expand All @@ -41,12 +41,12 @@ public PhysicalFileProviderResult(string fileName, string contentType)
}

/// <summary>
/// Creates a new <see cref="PhysicalFileProviderResult"/> instance with
/// Creates a new <see cref="PhysicalFileResult"/> instance with
/// the provided <paramref name="fileName"/> and the provided <paramref name="contentType"/>.
/// </summary>
/// <param name="fileName">The path to the file. The path must be an absolute path.</param>
/// <param name="contentType">The Content-Type header of the response.</param>
public PhysicalFileProviderResult(string fileName, MediaTypeHeaderValue contentType)
public PhysicalFileResult(string fileName, MediaTypeHeaderValue contentType)
: base(contentType)
{
if (fileName == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ namespace Microsoft.AspNet.Mvc
/// A <see cref="FileResult" /> that on execution writes the file specified using a virtual path to the response
/// using mechanisms provided by the host.
/// </summary>
public class VirtualFileProviderResult : FileResult
public class VirtualFileResult : FileResult
{
private const int DefaultBufferSize = 0x1000;
private string _fileName;

/// <summary>
/// Creates a new <see cref="VirtualFileProviderResult"/> instance with the provided <paramref name="fileName"/>
/// Creates a new <see cref="VirtualFileResult"/> instance with the provided <paramref name="fileName"/>
/// and the provided <paramref name="contentType"/>.
/// </summary>
/// <param name="fileName">The path to the file. The path must be relative/virtual.</param>
/// <param name="contentType">The Content-Type header of the response.</param>
public VirtualFileProviderResult(string fileName, string contentType)
public VirtualFileResult(string fileName, string contentType)
: this(fileName, new MediaTypeHeaderValue(contentType))
{
if (fileName == null)
Expand All @@ -44,13 +44,13 @@ public VirtualFileProviderResult(string fileName, string contentType)
}

/// <summary>
/// Creates a new <see cref="VirtualFileProviderResult"/> instance with
/// Creates a new <see cref="VirtualFileResult"/> instance with
/// the provided <paramref name="fileName"/> and the
/// provided <paramref name="contentType"/>.
/// </summary>
/// <param name="fileName">The path to the file. The path must be relative/virtual.</param>
/// <param name="contentType">The Content-Type header of the response.</param>
public VirtualFileProviderResult(string fileName, MediaTypeHeaderValue contentType)
public VirtualFileResult(string fileName, MediaTypeHeaderValue contentType)
: base(contentType)
{
if (fileName == null)
Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,9 @@ public virtual FileStreamResult File(Stream fileStream, string contentType, stri
/// </summary>
/// <param name="virtualPath">The virtual path of the file to be returned.</param>
/// <param name="contentType">The Content-Type of the file.</param>
/// <returns>The created <see cref="VirtualFileProviderResult"/> for the response.</returns>
/// <returns>The created <see cref="VirtualFileResult"/> for the response.</returns>
[NonAction]
public virtual VirtualFileProviderResult File(string virtualPath, string contentType)
public virtual VirtualFileResult File(string virtualPath, string contentType)
{
return File(virtualPath, contentType, fileDownloadName: null);
}
Expand All @@ -893,11 +893,11 @@ public virtual VirtualFileProviderResult File(string virtualPath, string content
/// <param name="virtualPath">The virtual path of the file to be returned.</param>
/// <param name="contentType">The Content-Type of the file.</param>
/// <param name="fileDownloadName">The suggested file name.</param>
/// <returns>The created <see cref="VirtualFileProviderResult"/> for the response.</returns>
/// <returns>The created <see cref="VirtualFileResult"/> for the response.</returns>
[NonAction]
public virtual VirtualFileProviderResult File(string virtualPath, string contentType, string fileDownloadName)
public virtual VirtualFileResult File(string virtualPath, string contentType, string fileDownloadName)
{
return new VirtualFileProviderResult(virtualPath, contentType) { FileDownloadName = fileDownloadName };
return new VirtualFileResult(virtualPath, contentType) { FileDownloadName = fileDownloadName };
}

/// <summary>
Expand All @@ -906,9 +906,9 @@ public virtual VirtualFileProviderResult File(string virtualPath, string content
/// </summary>
/// <param name="physicalPath">The physical path of the file to be returned.</param>
/// <param name="contentType">The Content-Type of the file.</param>
/// <returns>The created <see cref="PhysicalFileProviderResult"/> for the response.</returns>
/// <returns>The created <see cref="PhysicalFileResult"/> for the response.</returns>
[NonAction]
public virtual PhysicalFileProviderResult PhysicalFile(string physicalPath, string contentType)
public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType)
{
return PhysicalFile(physicalPath, contentType, fileDownloadName: null);
}
Expand All @@ -921,14 +921,14 @@ public virtual PhysicalFileProviderResult PhysicalFile(string physicalPath, stri
/// <param name="physicalPath">The physical path of the file to be returned.</param>
/// <param name="contentType">The Content-Type of the file.</param>
/// <param name="fileDownloadName">The suggested file name.</param>
/// <returns>The created <see cref="PhysicalFileProviderResult"/> for the response.</returns>
/// <returns>The created <see cref="PhysicalFileResult"/> for the response.</returns>
[NonAction]
public virtual PhysicalFileProviderResult PhysicalFile(
public virtual PhysicalFileResult PhysicalFile(
string physicalPath,
string contentType,
string fileDownloadName)
{
return new PhysicalFileProviderResult(physicalPath, contentType) { FileDownloadName = fileDownloadName };
return new PhysicalFileResult(physicalPath, contentType) { FileDownloadName = fileDownloadName };
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.AspNet.Mvc
{
public class PhysicalFileProviderResultTest
public class PhysicalFileResultTest
{
[Fact]
public void Constructor_SetsFileName()
Expand All @@ -24,7 +24,7 @@ public void Constructor_SetsFileName()
var path = Path.GetFullPath("helllo.txt");

// Act
var result = new PhysicalFileProviderResult(path, "text/plain");
var result = new PhysicalFileResult(path, "text/plain");

// Assert
Assert.Equal(path, result.FileName);
Expand All @@ -35,7 +35,7 @@ public async Task ExecuteResultAsync_FallsbackToStreamCopy_IfNoIHttpSendFilePres
{
// Arrange
var path = Path.GetFullPath(Path.Combine("TestFiles", "FilePathResultTestFile.txt"));
var result = new TestPhysicalFileProviderResult(path, "text/plain");
var result = new TestPhysicalFileResult(path, "text/plain");
var httpContext = new DefaultHttpContext();
httpContext.Response.Body = new MemoryStream();
var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
Expand All @@ -55,7 +55,7 @@ public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent()
{
// Arrange
var path = Path.GetFullPath(Path.Combine("TestFiles", "FilePathResultTestFile.txt"));
var result = new PhysicalFileProviderResult(path, "text/plain");
var result = new PhysicalFileResult(path, "text/plain");
var sendFileMock = new Mock<IHttpSendFileFeature>();
sendFileMock
.Setup(s => s.SendFileAsync(path, 0, null, CancellationToken.None))
Expand All @@ -78,7 +78,7 @@ public async Task ExecuteResultAsync_SetsSuppliedContentTypeAndEncoding()
// Arrange
var expectedContentType = "text/foo; charset=us-ascii";
var path = Path.GetFullPath(Path.Combine(".", "TestFiles", "FilePathResultTestFile_ASCII.txt"));
var result = new TestPhysicalFileProviderResult(path, MediaTypeHeaderValue.Parse(expectedContentType))
var result = new TestPhysicalFileResult(path, MediaTypeHeaderValue.Parse(expectedContentType))
{
IsAscii = true
};
Expand All @@ -101,7 +101,7 @@ public async Task ExecuteResultAsync_WorksWithAbsolutePaths()
{
// Arrange
var path = Path.GetFullPath(Path.Combine(".", "TestFiles", "FilePathResultTestFile.txt"));
var result = new TestPhysicalFileProviderResult(path, "text/plain");
var result = new TestPhysicalFileResult(path, "text/plain");

var httpContext = new DefaultHttpContext();
httpContext.Response.Body = new MemoryStream();
Expand Down Expand Up @@ -134,7 +134,7 @@ public async Task ExecuteResultAsync_WorksWithAbsolutePaths()
public async Task ExecuteAsync_ThrowsFileNotFound_ForNonRootedPaths(string path)
{
// Arrange
var result = new TestPhysicalFileProviderResult(path, "text/plain");
var result = new TestPhysicalFileResult(path, "text/plain");
var context = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
var expectedMessage = "Could not find file: " + path;

Expand All @@ -158,7 +158,7 @@ public async Task ExecuteAsync_ThrowsFileNotFound_ForNonRootedPaths(string path)
public void ExecuteAsync_ThrowsDirectoryNotFound_IfItCanNotFindTheDirectory_ForRootPaths(string path)
{
// Arrange
var result = new TestPhysicalFileProviderResult(path, "text/plain");
var result = new TestPhysicalFileResult(path, "text/plain");
var context = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());

// Act & Assert
Expand All @@ -171,21 +171,21 @@ public void ExecuteAsync_ThrowsDirectoryNotFound_IfItCanNotFindTheDirectory_ForR
public void ExecuteAsync_ThrowsFileNotFound_WhenFileDoesNotExist_ForRootPaths(string path)
{
// Arrange
var result = new TestPhysicalFileProviderResult(path, "text/plain");
var result = new TestPhysicalFileResult(path, "text/plain");
var context = new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());

// Act & Assert
Assert.ThrowsAsync<FileNotFoundException>(() => result.ExecuteResultAsync(context));
}

private class TestPhysicalFileProviderResult : PhysicalFileProviderResult
private class TestPhysicalFileResult : PhysicalFileResult
{
public TestPhysicalFileProviderResult(string filePath, string contentType)
public TestPhysicalFileResult(string filePath, string contentType)
: base(filePath, contentType)
{
}

public TestPhysicalFileProviderResult(string filePath, MediaTypeHeaderValue contentType)
public TestPhysicalFileResult(string filePath, MediaTypeHeaderValue contentType)
: base(filePath, contentType)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Microsoft.AspNet.Mvc
{
public class VirtualFileProviderResultTest
public class VirtualFileResultTest
{
[Fact]
public void Constructor_SetsFileName()
Expand All @@ -27,7 +27,7 @@ public void Constructor_SetsFileName()
var path = Path.GetFullPath("helllo.txt");

// Act
var result = new VirtualFileProviderResult(path, "text/plain");
var result = new VirtualFileResult(path, "text/plain");

// Assert
Assert.Equal(path, result.FileName);
Expand All @@ -38,7 +38,7 @@ public async Task ExecuteResultAsync_FallsBackToWebRootFileProvider_IfNoFileProv
{
// Arrange
var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt");
var result = new TestVirtualFileProviderResult(path, "text/plain");
var result = new TestVirtualFileResult(path, "text/plain");

var appEnvironment = new Mock<IHostingEnvironment>();
appEnvironment.Setup(app => app.WebRootFileProvider)
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task ExecuteResultAsync_FallsbackToStreamCopy_IfNoIHttpSendFilePres
{
// Arrange
var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt");
var result = new TestVirtualFileProviderResult(path, "text/plain")
var result = new TestVirtualFileResult(path, "text/plain")
{
FileProvider = GetFileProvider(path),
};
Expand All @@ -90,7 +90,7 @@ public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent()
{
// Arrange
var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt");
var result = new TestVirtualFileProviderResult(path, "text/plain")
var result = new TestVirtualFileResult(path, "text/plain")
{
FileProvider = GetFileProvider(path),
};
Expand All @@ -116,7 +116,7 @@ public async Task ExecuteResultAsync_SetsSuppliedContentTypeAndEncoding()
{
// Arrange
var expectedContentType = "text/foo; charset=us-ascii";
var result = new TestVirtualFileProviderResult(
var result = new TestVirtualFileResult(
"FilePathResultTestFile_ASCII.txt", MediaTypeHeaderValue.Parse(expectedContentType))
{
FileProvider = GetFileProvider("FilePathResultTestFile_ASCII.txt"),
Expand All @@ -142,7 +142,7 @@ public async Task ExecuteResultAsync_ReturnsFileContentsForRelativePaths()
{
// Arrange
var path = Path.Combine("TestFiles", "FilePathResultTestFile.txt");
var result = new TestVirtualFileProviderResult(path, "text/plain")
var result = new TestVirtualFileResult(path, "text/plain")
{
FileProvider = GetFileProvider(path),
};
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task ExecuteResultAsync_ReturnsFileContentsForRelativePaths()
public async Task ExecuteResultAsync_ReturnsFiles_ForDifferentPaths(string path)
{
// Arrange
var result = new TestVirtualFileProviderResult(path, "text/plain")
var result = new TestVirtualFileResult(path, "text/plain")
{
FileProvider = GetFileProvider(path),
};
Expand Down Expand Up @@ -207,7 +207,7 @@ public async Task ExecuteResultAsync_WorksWithNonDiskBasedFiles()
var nonDiskFileProvider = new Mock<IFileProvider>();
nonDiskFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny<string>())).Returns(nonDiskFileInfo.Object);

var filePathResult = new VirtualFileProviderResult("/SampleEmbeddedFile.txt", "text/plain")
var filePathResult = new VirtualFileResult("/SampleEmbeddedFile.txt", "text/plain")
{
FileProvider = nonDiskFileProvider.Object
};
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task ExecuteResultAsync_ThrowsFileNotFound_IfFileProviderCanNotFind
// Arrange
// Point the IFileProvider root to a different subfolder
var fileProvider = new PhysicalFileProvider(Path.GetFullPath("./Properties"));
var filePathResult = new VirtualFileProviderResult(path, "text/plain")
var filePathResult = new VirtualFileResult(path, "text/plain")
{
FileProvider = fileProvider,
};
Expand Down Expand Up @@ -275,7 +275,7 @@ public void ExecuteResultAsync_ThrowsDirectoryNotFound_IfFileProviderCanNotFindT
// Arrange
// Point the IFileProvider root to a different subfolder
var fileProvider = new PhysicalFileProvider(Path.GetFullPath("./Properties"));
var filePathResult = new VirtualFileProviderResult(path, "text/plain")
var filePathResult = new VirtualFileResult(path, "text/plain")
{
FileProvider = fileProvider,
};
Expand All @@ -297,14 +297,14 @@ private IFileProvider GetFileProvider(string path)
return fileProvider.Object;
}

private class TestVirtualFileProviderResult : VirtualFileProviderResult
private class TestVirtualFileResult : VirtualFileResult
{
public TestVirtualFileProviderResult(string filePath, string contentType)
public TestVirtualFileResult(string filePath, string contentType)
: base(filePath, contentType)
{
}

public TestVirtualFileProviderResult(string filePath, MediaTypeHeaderValue contentType)
public TestVirtualFileResult(string filePath, MediaTypeHeaderValue contentType)
: base(filePath, contentType)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EmbeddedFilesController : Controller
{
public IActionResult DownloadFileWithFileName()
{
return new VirtualFileProviderResult("/Greetings.txt", "text/plain")
return new VirtualFileResult("/Greetings.txt", "text/plain")
{
FileProvider = new EmbeddedFileProvider(GetType().GetTypeInfo().Assembly, "FilesWebSite.EmbeddedResources"),
FileDownloadName = "downloadName.txt"
Expand Down

0 comments on commit eef6c38

Please sign in to comment.