From 42eb25c3e8bcb20860799f94861bda6f0aadde7b Mon Sep 17 00:00:00 2001 From: enisn Date: Tue, 5 Jan 2021 09:54:35 +0300 Subject: [PATCH] CmsKit - Add new tests to Content --- .../Contents/ContentAdminAppService_Tests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentAdminAppService_Tests.cs index b7d2d4d80d..a33f61cedc 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentAdminAppService_Tests.cs @@ -61,6 +61,29 @@ namespace Volo.CmsKit.Contents created.ShouldNotBeNull(); } + [Fact] + public async Task ShouldNotCreateWithSameParametersAsync() + { + var entityTtype = "My.Awesome.Book"; + var entityId = "1"; + + await _service.CreateAsync(new ContentCreateDto + { + EntityId = entityId, + EntityType = entityTtype, + Value = "Some long content" + }); + + await Should.ThrowAsync(async () => + await _service.CreateAsync(new ContentCreateDto + { + EntityId = entityId, + EntityType = entityTtype, + Value = "Yet another long content" + }) + ); + } + [Fact] public async Task ShouldUpdateAsync() { @@ -84,5 +107,21 @@ namespace Volo.CmsKit.Contents await Should.ThrowAsync(async () => await _service.GetAsync(_data.Content_2_Id)); } + + [Fact] + public async Task ShouldThrowEntityNotFoundExceptionWhileDeletingNonExistingAsync() + { + await Should.ThrowAsync(async () => + await _service.DeleteAsync(Guid.NewGuid())); // Freshly generated non-existing id. + } + + [Fact] + public async Task ShouldThrowEntityNotFoundExceptionWhileDeletingAlreadyDeletedAsync() + { + await _service.DeleteAsync(_data.Content_2_Id); + + Should.ThrowAsync(async () => + await _service.DeleteAsync(_data.Content_2_Id)); + } } }