Browse Source

Add unit tests

pull/14365/head
liangshiwei 3 years ago
parent
commit
31e5a079d7
  1. 10
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs
  2. 13
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs

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

@ -30,6 +30,16 @@ public class RemoteStreamContentTestController : AbpController
Response.Headers.Add("Content-Disposition", "attachment; filename=myDownload.rtf");
return new RemoteStreamContent(memoryStream, "download.rtf", "application/rtf");
}
[HttpGet]
[Route("Download_With_Chinese_File_Name")]
public async Task<IRemoteStreamContent> Download_With_Chinese_File_Name_Async()
{
var memoryStream = new MemoryStream();
await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("DownloadAsync"));
memoryStream.Position = 0;
return new RemoteStreamContent(memoryStream, "下载文件.rtf", "application/rtf");
}
[HttpPost]
[Route("Upload")]

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

@ -3,6 +3,7 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Shouldly;
using Xunit;
@ -20,7 +21,7 @@ public class RemoteStreamContentTestController_Tests : AspNetCoreMvcTestBase
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
}
[Fact]
[Fact]
public async Task Download_With_Custom_Content_Disposition_Async()
{
var result = await GetResponseAsync("/api/remote-stream-content-test/download-with-custom-content-disposition");
@ -29,6 +30,16 @@ public class RemoteStreamContentTestController_Tests : AspNetCoreMvcTestBase
result.Content.Headers.ContentLength.ShouldBe("DownloadAsync".Length);
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
}
[Fact]
public async Task Download_With_Chinese_File_Name_Async()
{
var result = await GetResponseAsync("/api/remote-stream-content-test/download_with_chinese_file_name");
result.Content.Headers.ContentType?.ToString().ShouldBe("application/rtf");
result.Content.Headers.ContentDisposition?.FileNameStar.ShouldBe("下载文件.rtf");
result.Content.Headers.ContentLength.ShouldBe("DownloadAsync".Length);
(await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
}
[Fact]
public async Task UploadAsync()

Loading…
Cancel
Save