PhysicalFileResultTest.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Internal;
  6. using Microsoft.Net.Http.Headers;
  7. namespace Microsoft.AspNetCore.Http.Result
  8. {
  9. public class PhysicalFileResultTest : PhysicalFileResultTestBase
  10. {
  11. protected override Task ExecuteAsync(
  12. HttpContext httpContext,
  13. string path,
  14. string contentType,
  15. DateTimeOffset? lastModified = null,
  16. EntityTagHeaderValue entityTag = null,
  17. bool enableRangeProcessing = false)
  18. {
  19. var fileResult = new PhysicalFileResult(path, contentType)
  20. {
  21. LastModified = lastModified,
  22. EntityTag = entityTag,
  23. EnableRangeProcessing = enableRangeProcessing,
  24. GetFileInfoWrapper = (path) =>
  25. {
  26. var lastModified = DateTimeOffset.MinValue.AddDays(1);
  27. return new()
  28. {
  29. Exists = true,
  30. Length = 34,
  31. LastWriteTimeUtc = new DateTimeOffset(lastModified.Year, lastModified.Month, lastModified.Day, lastModified.Hour, lastModified.Minute, lastModified.Second, TimeSpan.FromSeconds(0))
  32. };
  33. }
  34. };
  35. return fileResult.ExecuteAsync(httpContext);
  36. }
  37. }
  38. }