예제 #1
0
        public async void GetDownload_Test()
        {
            var r = await Controller.GetDownload("123-Mock-321");

            Assert.True(r is FileStreamResult, $"r should be FileStreamResult, not {r.GetType().Name}");
            var Result = r as FileStreamResult;

            Assert.NotNull(Result);
            Assert.Equal("application/pdf", Result.ContentType);
            Assert.Matches("Issues-.{4}-.{2}-.{2}.pdf", Result.FileDownloadName);
            await using (var ms = new MemoryStream())
            {
                await Result.FileStream.CopyToAsync(ms);

                Assert.Equal("file 123-Mock-321.pdf content", Encoding.UTF8.GetString(ms.ToArray()));
            }
        }