Browse Source

CmsKit - Add new tests to Content

pull/6926/head
enisn 6 years ago
parent
commit
42eb25c3e8
  1. 39
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Contents/ContentAdminAppService_Tests.cs

39
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<Exception>(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<EntityNotFoundException>(async () => await _service.GetAsync(_data.Content_2_Id));
}
[Fact]
public async Task ShouldThrowEntityNotFoundExceptionWhileDeletingNonExistingAsync()
{
await Should.ThrowAsync<EntityNotFoundException>(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<EntityNotFoundException>(async () =>
await _service.DeleteAsync(_data.Content_2_Id));
}
}
}

Loading…
Cancel
Save