public void Constructor_SetsFileName()
        {
            // Arrange
            var path = Path.GetFullPath("helllo.txt");

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

            // Assert
            Assert.Equal(path, result.FileName);
        }
        public void Constructor_SetsFileName()
        {
            // Arrange
            var path = Path.GetFullPath("helllo.txt");

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

            // Assert
            Assert.Equal(path, result.FileName);
        }
        internal static bool TryGetCachedCompositeFileResult(FileSystemHelper fileSystemHelper, string filesetKey, CompressionType type, string mime, 
            out FileResult result, out DateTime lastWriteTime)
        {
            result = null;
            lastWriteTime = DateTime.Now;

            var filesetPath = fileSystemHelper.GetCurrentCompositeFilePath(type, filesetKey);
            if (System.IO.File.Exists(filesetPath))
            {
                lastWriteTime = System.IO.File.GetLastWriteTime(filesetPath);
                //FilePathResult uses IHttpSendFileFeature which is a native host option for sending static files
                result = new PhysicalFileProviderResult(filesetPath, mime);
                return true;
            }

            return false;
        }
        public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent()
        {
            // Arrange
            var path = Path.GetFullPath(Path.Combine("TestFiles", "FilePathResultTestFile.txt"));
            var result = new PhysicalFileProviderResult(path, "text/plain");
            var sendFileMock = new Mock<IHttpSendFileFeature>();
            sendFileMock
                .Setup(s => s.SendFileAsync(path, 0, null, CancellationToken.None))
                .Returns(Task.FromResult<int>(0));

            var httpContext = new DefaultHttpContext();
            httpContext.Features.Set(sendFileMock.Object);
            var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());

            // Act
            await result.ExecuteResultAsync(context);

            // Assert
            sendFileMock.Verify();
        }
        public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent()
        {
            // Arrange
            var path         = Path.GetFullPath(Path.Combine("TestFiles", "FilePathResultTestFile.txt"));
            var result       = new PhysicalFileProviderResult(path, "text/plain");
            var sendFileMock = new Mock <IHttpSendFileFeature>();

            sendFileMock
            .Setup(s => s.SendFileAsync(path, 0, null, CancellationToken.None))
            .Returns(Task.FromResult <int>(0));

            var httpContext = new DefaultHttpContext();

            httpContext.Features.Set(sendFileMock.Object);
            var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());

            // Act
            await result.ExecuteResultAsync(context);

            // Assert
            sendFileMock.Verify();
        }