blog admin separation: fix unit tests & rename app service methods

pull/4236/head
Yunus Emre Kalkan 5 years ago
parent 50f7ad93ca
commit 022c1bc3d0

@ -11,10 +11,10 @@ namespace Volo.Blogging.Admin.Blogs
Task<BlogDto> GetAsync(Guid id); Task<BlogDto> GetAsync(Guid id);
Task<BlogDto> Create(CreateBlogDto input); Task<BlogDto> CreateAsync(CreateBlogDto input);
Task<BlogDto> Update(Guid id, UpdateBlogDto input); Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input);
Task Delete(Guid id); Task DeleteAsync(Guid id);
} }
} }

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -33,7 +33,7 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingAdminPermissions.Blogs.Create)] [Authorize(BloggingAdminPermissions.Blogs.Create)]
public async Task<BlogDto> Create(CreateBlogDto input) public async Task<BlogDto> CreateAsync(CreateBlogDto input)
{ {
var newBlog = await _blogRepository.InsertAsync(new Blog(GuidGenerator.Create(), input.Name, input.ShortName) var newBlog = await _blogRepository.InsertAsync(new Blog(GuidGenerator.Create(), input.Name, input.ShortName)
{ {
@ -44,7 +44,7 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingAdminPermissions.Blogs.Update)] [Authorize(BloggingAdminPermissions.Blogs.Update)]
public async Task<BlogDto> Update(Guid id, UpdateBlogDto input) public async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
{ {
var blog = await _blogRepository.GetAsync(id); var blog = await _blogRepository.GetAsync(id);
@ -56,7 +56,7 @@ namespace Volo.Blogging.Admin.Blogs
} }
[Authorize(BloggingAdminPermissions.Blogs.Delete)] [Authorize(BloggingAdminPermissions.Blogs.Delete)]
public async Task Delete(Guid id) public async Task DeleteAsync(Guid id)
{ {
await _blogRepository.DeleteAsync(id); await _blogRepository.DeleteAsync(id);
} }

@ -34,23 +34,23 @@ namespace Volo.Blogging.Admin
} }
[HttpPost] [HttpPost]
public async Task<BlogDto> Create(CreateBlogDto input) public async Task<BlogDto> CreateAsync(CreateBlogDto input)
{ {
return await _blogManagementAppService.Create(input); return await _blogManagementAppService.CreateAsync(input);
} }
[HttpPut] [HttpPut]
[Route("{id}")] [Route("{id}")]
public async Task<BlogDto> Update(Guid id, UpdateBlogDto input) public async Task<BlogDto> UpdateAsync(Guid id, UpdateBlogDto input)
{ {
return await _blogManagementAppService.Update(id, input); return await _blogManagementAppService.UpdateAsync(id, input);
} }
[HttpDelete] [HttpDelete]
[Route("{id}")] [Route("{id}")]
public async Task Delete(Guid id) public async Task DeleteAsync(Guid id)
{ {
await _blogManagementAppService.Delete(id); await _blogManagementAppService.DeleteAsync(id);
} }
} }
} }

@ -35,7 +35,7 @@ namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs
{ {
var blogDto = ObjectMapper.Map<BlogCreateModalView, CreateBlogDto>(Blog); var blogDto = ObjectMapper.Map<BlogCreateModalView, CreateBlogDto>(Blog);
await _blogAppService.Create(blogDto); await _blogAppService.CreateAsync(blogDto);
return NoContent(); return NoContent();
} }

@ -41,7 +41,7 @@ namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs
public virtual async Task<IActionResult> OnPostAsync() public virtual async Task<IActionResult> OnPostAsync()
{ {
await _blogAppService.Update(Blog.Id, new UpdateBlogDto() await _blogAppService.UpdateAsync(Blog.Id, new UpdateBlogDto()
{ {
Name = Blog.Name, Name = Blog.Name,
ShortName = Blog.ShortName, ShortName = Blog.ShortName,

@ -11,6 +11,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Volo.Blogging.Application\Volo.Blogging.Application.csproj" /> <ProjectReference Include="..\..\src\Volo.Blogging.Application\Volo.Blogging.Application.csproj" />
<ProjectReference Include="..\..\src\Volo.Blogging.Admin.Application\Volo.Blogging.Admin.Application.csproj" />
<ProjectReference Include="..\..\src\Volo.Blogging.Web\Volo.Blogging.Web.csproj" /> <ProjectReference Include="..\..\src\Volo.Blogging.Web\Volo.Blogging.Web.csproj" />
<ProjectReference Include="..\Volo.Blogging.Domain.Tests\Volo.Blogging.Domain.Tests.csproj" /> <ProjectReference Include="..\Volo.Blogging.Domain.Tests\Volo.Blogging.Domain.Tests.csproj" />
</ItemGroup> </ItemGroup>

@ -1,13 +1,9 @@
using System; using System.Linq;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Shouldly; using Shouldly;
using Volo.Blogging.Blogs; using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Comments;
using Volo.Blogging.Comments.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers; using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts; using Volo.Blogging.Admin.Blogs;
using Xunit; using Xunit;
namespace Volo.Blogging namespace Volo.Blogging
@ -15,11 +11,13 @@ namespace Volo.Blogging
public class BlogAppService_Tests : BloggingApplicationTestBase public class BlogAppService_Tests : BloggingApplicationTestBase
{ {
private readonly IBlogAppService _blogAppService; private readonly IBlogAppService _blogAppService;
private readonly IBlogManagementAppService _blogManagementAppService;
private readonly IBlogRepository _blogRepository; private readonly IBlogRepository _blogRepository;
public BlogAppService_Tests() public BlogAppService_Tests()
{ {
_blogAppService = GetRequiredService<IBlogAppService>(); _blogAppService = GetRequiredService<IBlogAppService>();
_blogManagementAppService = GetRequiredService<IBlogManagementAppService>();
_blogRepository = GetRequiredService<IBlogRepository>(); _blogRepository = GetRequiredService<IBlogRepository>();
} }
@ -68,7 +66,7 @@ namespace Volo.Blogging
var shortName = "test shortName"; var shortName = "test shortName";
var description = "test description"; var description = "test description";
var blogDto = await _blogAppService.Create(new CreateBlogDto() { Name = name, ShortName = name, Description = description }); var blogDto = await _blogManagementAppService.CreateAsync(new CreateBlogDto() { Name = name, ShortName = name, Description = description });
UsingDbContext(context => UsingDbContext(context =>
{ {
@ -85,9 +83,9 @@ namespace Volo.Blogging
{ {
var newDescription = "new description"; var newDescription = "new description";
var oldBlog = (await _blogRepository.GetListAsync()).FirstOrDefault(); ; var oldBlog = (await _blogManagementAppService.GetListAsync()).Items.FirstOrDefault(); ;
await _blogAppService.Update(oldBlog.Id, new UpdateBlogDto() await _blogManagementAppService.UpdateAsync(oldBlog.Id, new UpdateBlogDto()
{ Description = newDescription, Name = oldBlog.Name, ShortName = oldBlog.ShortName }); { Description = newDescription, Name = oldBlog.Name, ShortName = oldBlog.ShortName });
UsingDbContext(context => UsingDbContext(context =>
@ -102,7 +100,7 @@ namespace Volo.Blogging
{ {
var blog = (await _blogRepository.GetListAsync()).First(); var blog = (await _blogRepository.GetListAsync()).First();
await _blogAppService.Delete(blog.Id); await _blogManagementAppService.DeleteAsync(blog.Id);
} }
} }
} }

@ -1,11 +1,13 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Blogging.Admin;
using Volo.Blogging.EntityFrameworkCore; using Volo.Blogging.EntityFrameworkCore;
namespace Volo.Blogging namespace Volo.Blogging
{ {
[DependsOn( [DependsOn(
typeof(BloggingApplicationModule), typeof(BloggingApplicationModule),
typeof(BloggingAdminApplicationModule),
typeof(BloggingEntityFrameworkCoreTestModule), typeof(BloggingEntityFrameworkCoreTestModule),
typeof(BloggingTestBaseModule))] typeof(BloggingTestBaseModule))]
public class BloggingApplicationTestModule : AbpModule public class BloggingApplicationTestModule : AbpModule

Loading…
Cancel
Save