mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace Volo.CmsKit.Blogs;
|
|
|
|
public class BlogManager_Test : CmsKitDomainTestBase
|
|
{
|
|
protected IBlogRepository BlogRepository { get; }
|
|
protected BlogManager BlogManager { get; }
|
|
protected CmsKitTestData TestData { get; }
|
|
|
|
public BlogManager_Test()
|
|
{
|
|
BlogRepository = GetRequiredService<IBlogRepository>();
|
|
BlogManager = GetRequiredService<BlogManager>();
|
|
TestData = GetRequiredService<CmsKitTestData>();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task BlogCreate_ShouldThrowException_WithExistSlug()
|
|
{
|
|
await Should.ThrowAsync<BlogSlugAlreadyExistException>(
|
|
async () =>
|
|
await BlogManager.CreateAsync("test-name", TestData.BlogSlug)
|
|
);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task BlogCreate_ShouldWorkProperly()
|
|
{
|
|
var blog = await BlogManager.CreateAsync("test-name", "test-slug");
|
|
|
|
blog.ShouldNotBeNull();
|
|
blog.Id.ShouldNotBe(Guid.Empty);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task BlogUpdate_ShouldWork()
|
|
{
|
|
var blog = await BlogRepository.GetAsync(TestData.Blog_Id);
|
|
|
|
await BlogManager.UpdateAsync(blog, "New name", "new-slug");
|
|
|
|
blog.Name.ShouldBe("New name");
|
|
blog.Slug.ShouldBe("new-slug");
|
|
}
|
|
}
|
|
|