Browse Source

Add unit tests

pull/14365/head
liangshiwei 4 years ago
parent
commit
f48ae49981
  1. 11
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs
  2. 10
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs

11
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs

@ -19,6 +19,17 @@ public class RemoteStreamContentTestController : AbpController
memoryStream.Position = 0; memoryStream.Position = 0;
return new RemoteStreamContent(memoryStream, "download.rtf", "application/rtf"); return new RemoteStreamContent(memoryStream, "download.rtf", "application/rtf");
} }
[HttpGet]
[Route("Download-With-Custom-Content-Disposition")]
public async Task<IRemoteStreamContent> Download_With_Custom_Content_Disposition_Async()
{
var memoryStream = new MemoryStream();
await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("DownloadAsync"));
memoryStream.Position = 0;
Response.Headers.Add("Content-Disposition", "attachment; filename=myDownload.rtf");
return new RemoteStreamContent(memoryStream, "download.rtf", "application/rtf");
}
[HttpPost] [HttpPost]
[Route("Upload")] [Route("Upload")]

10
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs

@ -19,6 +19,16 @@ public class RemoteStreamContentTestController_Tests : AspNetCoreMvcTestBase
result.Content.Headers.ContentLength.ShouldBe("DownloadAsync".Length); result.Content.Headers.ContentLength.ShouldBe("DownloadAsync".Length);
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync"); (await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
} }
[Fact]
public async Task Download_With_Custom_Content_Disposition_Async()
{
var result = await GetResponseAsync("/api/remote-stream-content-test/download-with-custom-content-disposition");
result.Content.Headers.ContentType?.ToString().ShouldBe("application/rtf");
result.Content.Headers.ContentDisposition?.FileName.ShouldBe("myDownload.rtf");
result.Content.Headers.ContentLength.ShouldBe("DownloadAsync".Length);
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
}
[Fact] [Fact]
public async Task UploadAsync() public async Task UploadAsync()

Loading…
Cancel
Save