mirror of https://github.com/abpframework/abp.git
3 changed files with 86 additions and 1 deletions
@ -0,0 +1,53 @@ |
|||
using System; |
|||
using System.IO; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Volo.CmsKit.Admin.MediaDescriptors; |
|||
using Xunit; |
|||
|
|||
namespace Volo.CmsKit.MediaDescriptors |
|||
{ |
|||
public class MediaDescriptorAdminAppService_Tests : CmsKitApplicationTestBase |
|||
{ |
|||
private readonly CmsKitTestData _cmsKitTestData; |
|||
private readonly IMediaDescriptorAdminAppService _mediaDescriptorAdminAppService; |
|||
private readonly IMediaDescriptorRepository _mediaDescriptorRepository; |
|||
|
|||
public MediaDescriptorAdminAppService_Tests() |
|||
{ |
|||
_cmsKitTestData = GetRequiredService<CmsKitTestData>(); |
|||
_mediaDescriptorAdminAppService = GetRequiredService<IMediaDescriptorAdminAppService>(); |
|||
_mediaDescriptorRepository = GetRequiredService<IMediaDescriptorRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Create_Media() |
|||
{ |
|||
var mediaName = "README.md"; |
|||
var mediaType = "text/markdown"; |
|||
var mediaContent = |
|||
"# ABP Framework\nABP Framework is a complete **infrastructure** based on the **ASP.NET Core** to create **modern web applications** and **APIs** by following the software development **best practices** and the **latest technologies**."; |
|||
|
|||
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(mediaContent)); |
|||
|
|||
var inputStream = new CreateMediaInputStream(stream) |
|||
{ |
|||
ContentType = mediaType, |
|||
Name = mediaName |
|||
}; |
|||
|
|||
var media = await _mediaDescriptorAdminAppService.CreateAsync(inputStream); |
|||
|
|||
media.ShouldNotBeNull(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Delete_Media() |
|||
{ |
|||
await _mediaDescriptorAdminAppService.DeleteAsync(_cmsKitTestData.Media_1_Id); |
|||
|
|||
(await _mediaDescriptorRepository.FindAsync(_cmsKitTestData.Media_1_Id)).ShouldBeNull(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue