From eef6c3883a7e27b8387b0925f0b6a88df0a484c5 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 1 Oct 2015 10:24:34 -0700 Subject: [PATCH] Renamed PhysicalFileProviderResult and VirtualFileProviderResult to PhysicalFileResult and VirtualFileResult respectively --- ...roviderResult.cs => PhysicalFileResult.cs} | 12 ++++---- ...ProviderResult.cs => VirtualFileResult.cs} | 10 +++---- .../Controller.cs | 20 ++++++------- ...esultTest.cs => PhysicalFileResultTest.cs} | 24 ++++++++-------- ...ResultTest.cs => VirtualFileResultTest.cs} | 28 +++++++++---------- .../Controllers/EmbeddedFilesController.cs | 2 +- 6 files changed, 48 insertions(+), 48 deletions(-) rename src/Microsoft.AspNet.Mvc.Core/{PhysicalFileProviderResult.cs => PhysicalFileResult.cs} (90%) rename src/Microsoft.AspNet.Mvc.Core/{VirtualFileProviderResult.cs => VirtualFileResult.cs} (92%) rename test/Microsoft.AspNet.Mvc.Core.Test/{PhysicalFileProviderResultTest.cs => PhysicalFileResultTest.cs} (88%) rename test/Microsoft.AspNet.Mvc.Core.Test/{VirtualFileProviderResultTest.cs => VirtualFileResultTest.cs} (91%) diff --git a/src/Microsoft.AspNet.Mvc.Core/PhysicalFileProviderResult.cs b/src/Microsoft.AspNet.Mvc.Core/PhysicalFileResult.cs similarity index 90% rename from src/Microsoft.AspNet.Mvc.Core/PhysicalFileProviderResult.cs rename to src/Microsoft.AspNet.Mvc.Core/PhysicalFileResult.cs index 979e8d9f64..06a8a9307f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/PhysicalFileProviderResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/PhysicalFileResult.cs @@ -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; @@ -16,18 +16,18 @@ namespace Microsoft.AspNet.Mvc /// A on execution will write a file from disk to the response /// using mechanisms provided by the host. /// - public class PhysicalFileProviderResult : FileResult + public class PhysicalFileResult : FileResult { private const int DefaultBufferSize = 0x1000; private string _fileName; /// - /// Creates a new instance with + /// Creates a new instance with /// the provided and the provided . /// /// The path to the file. The path must be an absolute path. /// The Content-Type header of the response. - public PhysicalFileProviderResult(string fileName, string contentType) + public PhysicalFileResult(string fileName, string contentType) : this(fileName, new MediaTypeHeaderValue(contentType)) { if (fileName == null) @@ -41,12 +41,12 @@ public PhysicalFileProviderResult(string fileName, string contentType) } /// - /// Creates a new instance with + /// Creates a new instance with /// the provided and the provided . /// /// The path to the file. The path must be an absolute path. /// The Content-Type header of the response. - public PhysicalFileProviderResult(string fileName, MediaTypeHeaderValue contentType) + public PhysicalFileResult(string fileName, MediaTypeHeaderValue contentType) : base(contentType) { if (fileName == null) diff --git a/src/Microsoft.AspNet.Mvc.Core/VirtualFileProviderResult.cs b/src/Microsoft.AspNet.Mvc.Core/VirtualFileResult.cs similarity index 92% rename from src/Microsoft.AspNet.Mvc.Core/VirtualFileProviderResult.cs rename to src/Microsoft.AspNet.Mvc.Core/VirtualFileResult.cs index d1c954f505..a1c6c7229a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/VirtualFileProviderResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/VirtualFileResult.cs @@ -19,18 +19,18 @@ namespace Microsoft.AspNet.Mvc /// A that on execution writes the file specified using a virtual path to the response /// using mechanisms provided by the host. /// - public class VirtualFileProviderResult : FileResult + public class VirtualFileResult : FileResult { private const int DefaultBufferSize = 0x1000; private string _fileName; /// - /// Creates a new instance with the provided + /// Creates a new instance with the provided /// and the provided . /// /// The path to the file. The path must be relative/virtual. /// The Content-Type header of the response. - public VirtualFileProviderResult(string fileName, string contentType) + public VirtualFileResult(string fileName, string contentType) : this(fileName, new MediaTypeHeaderValue(contentType)) { if (fileName == null) @@ -44,13 +44,13 @@ public VirtualFileProviderResult(string fileName, string contentType) } /// - /// Creates a new instance with + /// Creates a new instance with /// the provided and the /// provided . /// /// The path to the file. The path must be relative/virtual. /// The Content-Type header of the response. - public VirtualFileProviderResult(string fileName, MediaTypeHeaderValue contentType) + public VirtualFileResult(string fileName, MediaTypeHeaderValue contentType) : base(contentType) { if (fileName == null) diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs index 11c24c29fe..7a0de1faae 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Controller.cs @@ -878,9 +878,9 @@ public virtual FileStreamResult File(Stream fileStream, string contentType, stri /// /// The virtual path of the file to be returned. /// The Content-Type of the file. - /// The created for the response. + /// The created for the response. [NonAction] - public virtual VirtualFileProviderResult File(string virtualPath, string contentType) + public virtual VirtualFileResult File(string virtualPath, string contentType) { return File(virtualPath, contentType, fileDownloadName: null); } @@ -893,11 +893,11 @@ public virtual VirtualFileProviderResult File(string virtualPath, string content /// The virtual path of the file to be returned. /// The Content-Type of the file. /// The suggested file name. - /// The created for the response. + /// The created for the response. [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 }; } /// @@ -906,9 +906,9 @@ public virtual VirtualFileProviderResult File(string virtualPath, string content /// /// The physical path of the file to be returned. /// The Content-Type of the file. - /// The created for the response. + /// The created for the response. [NonAction] - public virtual PhysicalFileProviderResult PhysicalFile(string physicalPath, string contentType) + public virtual PhysicalFileResult PhysicalFile(string physicalPath, string contentType) { return PhysicalFile(physicalPath, contentType, fileDownloadName: null); } @@ -921,14 +921,14 @@ public virtual PhysicalFileProviderResult PhysicalFile(string physicalPath, stri /// The physical path of the file to be returned. /// The Content-Type of the file. /// The suggested file name. - /// The created for the response. + /// The created for the response. [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 }; } /// diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileProviderResultTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileResultTest.cs similarity index 88% rename from test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileProviderResultTest.cs rename to test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileResultTest.cs index 9a26501a3a..18e303194a 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileProviderResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/PhysicalFileResultTest.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc { - public class PhysicalFileProviderResultTest + public class PhysicalFileResultTest { [Fact] public void Constructor_SetsFileName() @@ -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); @@ -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()); @@ -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(); sendFileMock .Setup(s => s.SendFileAsync(path, 0, null, CancellationToken.None)) @@ -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 }; @@ -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(); @@ -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; @@ -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 @@ -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(() => 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) { } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileProviderResultTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileResultTest.cs similarity index 91% rename from test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileProviderResultTest.cs rename to test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileResultTest.cs index 0ee17513d2..cb2e5bddf7 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileProviderResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/VirtualFileResultTest.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc { - public class VirtualFileProviderResultTest + public class VirtualFileResultTest { [Fact] public void Constructor_SetsFileName() @@ -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); @@ -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(); appEnvironment.Setup(app => app.WebRootFileProvider) @@ -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), }; @@ -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), }; @@ -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"), @@ -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), }; @@ -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), }; @@ -207,7 +207,7 @@ public async Task ExecuteResultAsync_WorksWithNonDiskBasedFiles() var nonDiskFileProvider = new Mock(); nonDiskFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny())).Returns(nonDiskFileInfo.Object); - var filePathResult = new VirtualFileProviderResult("/SampleEmbeddedFile.txt", "text/plain") + var filePathResult = new VirtualFileResult("/SampleEmbeddedFile.txt", "text/plain") { FileProvider = nonDiskFileProvider.Object }; @@ -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, }; @@ -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, }; @@ -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) { } diff --git a/test/WebSites/FilesWebSite/Controllers/EmbeddedFilesController.cs b/test/WebSites/FilesWebSite/Controllers/EmbeddedFilesController.cs index 7d2cc5ac68..fec0ba8be5 100644 --- a/test/WebSites/FilesWebSite/Controllers/EmbeddedFilesController.cs +++ b/test/WebSites/FilesWebSite/Controllers/EmbeddedFilesController.cs @@ -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"