mirror of https://github.com/abpframework/abp.git
15 changed files with 382 additions and 21 deletions
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Docs.Admin.Projects; |
||||
|
using Volo.Docs.Projects; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public class ApplicationService_Tests : DocsApplicationTestBase |
||||
|
{ |
||||
|
private readonly IProjectAppService _projectAppService; |
||||
|
private readonly IProjectRepository _projectRepository; |
||||
|
private readonly DocsTestData _testData; |
||||
|
|
||||
|
public ApplicationService_Tests() |
||||
|
{ |
||||
|
_projectRepository = GetRequiredService<IProjectRepository>(); |
||||
|
_projectAppService = GetRequiredService<IProjectAppService>(); |
||||
|
_testData = GetRequiredService<DocsTestData>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync() |
||||
|
{ |
||||
|
var projects = await _projectAppService.GetListAsync(); |
||||
|
projects.ShouldNotBeNull(); |
||||
|
projects.Items.Count.ShouldBe(1); |
||||
|
projects.Items.ShouldContain(x => x.Id == _testData.PorjectId); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetAsync() |
||||
|
{ |
||||
|
var project = await _projectAppService.GetAsync("ABP"); |
||||
|
project.ShouldNotBeNull(); |
||||
|
project.ShortName.ShouldBe("ABP"); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetVersionsAsync() |
||||
|
{ |
||||
|
// TODO: Need to mock WebClient and Octokit components
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,14 +0,0 @@ |
|||||
using Volo.Abp.Modularity; |
|
||||
using Volo.Docs.Admin; |
|
||||
|
|
||||
namespace Volo.Docs |
|
||||
{ |
|
||||
[DependsOn( |
|
||||
typeof(DocsAdminApplicationModule), |
|
||||
typeof(DocsDomainTestModule) |
|
||||
)] |
|
||||
public class DocsApplicationTestModule : AbpModule |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public class DocsAdminApplicationTestBase : DocsTestBase<DocsAdminApplicationTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public class DocsApplicationTestBase : DocsTestBase<DocsApplicationTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Docs.Admin; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(DocsApplicationModule), |
||||
|
typeof(DocsDomainTestModule) |
||||
|
)] |
||||
|
public class DocsApplicationTestModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(DocsAdminApplicationModule), |
||||
|
typeof(DocsDomainTestModule) |
||||
|
)] |
||||
|
public class DocsAdminApplicationTestModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,124 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Docs.Admin.Projects; |
||||
|
using Volo.Docs.Projects; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public class ProjectAdminAppService_Tests : DocsAdminApplicationTestBase |
||||
|
{ |
||||
|
private readonly IProjectAdminAppService _projectAdminAppService; |
||||
|
private readonly IProjectRepository _projectRepository; |
||||
|
private readonly DocsTestData _testData; |
||||
|
|
||||
|
public ProjectAdminAppService_Tests() |
||||
|
{ |
||||
|
_projectRepository = GetRequiredService<IProjectRepository>(); |
||||
|
_projectAdminAppService = GetRequiredService<IProjectAdminAppService>(); |
||||
|
_testData = GetRequiredService<DocsTestData>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync() |
||||
|
{ |
||||
|
var projects = await _projectAdminAppService.GetListAsync(new PagedAndSortedResultRequestDto()); |
||||
|
projects.ShouldNotBeNull(); |
||||
|
projects.TotalCount.ShouldBe(1); |
||||
|
projects.Items.ShouldContain(x => x.Name == "ABP vNext"); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetAsync() |
||||
|
{ |
||||
|
var project = await _projectAdminAppService.GetAsync(_testData.PorjectId); |
||||
|
project.ShouldNotBeNull(); |
||||
|
project.Id.ShouldBe(_testData.PorjectId); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task CreateAsync() |
||||
|
{ |
||||
|
var createProjectDto = new CreateProjectDto |
||||
|
{ |
||||
|
Name = "ABP vNext", |
||||
|
ShortName = "ABP", |
||||
|
Format = "md", |
||||
|
DefaultDocumentName = "index", |
||||
|
NavigationDocumentName = "docs-nav.json", |
||||
|
MinimumVersion = "1", |
||||
|
MainWebsiteUrl = "abp.io", |
||||
|
LatestVersionBranchName = "", |
||||
|
DocumentStoreType = "GitHub", |
||||
|
ExtraProperties = new Dictionary<string, object>() |
||||
|
}; |
||||
|
createProjectDto.ExtraProperties.Add("GitHubRootUrl", |
||||
|
"https://github.com/abpframework/abp/tree/{version}/docs/en/"); |
||||
|
createProjectDto.ExtraProperties.Add("GitHubAccessToken", "123456"); |
||||
|
createProjectDto.ExtraProperties.Add("GitHubUserAgent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); |
||||
|
|
||||
|
//Act
|
||||
|
var projectDto = await _projectAdminAppService.CreateAsync(createProjectDto); |
||||
|
projectDto.ShouldNotBeNull(); |
||||
|
projectDto.Name.ShouldBe(createProjectDto.Name); |
||||
|
projectDto.ShortName.ShouldBe(createProjectDto.ShortName); |
||||
|
projectDto.Format.ShouldBe(createProjectDto.Format); |
||||
|
projectDto.DefaultDocumentName.ShouldBe(createProjectDto.DefaultDocumentName); |
||||
|
projectDto.NavigationDocumentName.ShouldBe(createProjectDto.NavigationDocumentName); |
||||
|
projectDto.MinimumVersion.ShouldBe(createProjectDto.MinimumVersion); |
||||
|
projectDto.MainWebsiteUrl.ShouldBe(createProjectDto.MainWebsiteUrl); |
||||
|
projectDto.LatestVersionBranchName.ShouldBe(createProjectDto.LatestVersionBranchName); |
||||
|
projectDto.DocumentStoreType.ShouldBe(createProjectDto.DocumentStoreType); |
||||
|
|
||||
|
projectDto.ExtraProperties.Except(createProjectDto.ExtraProperties).Any().ShouldBe(false); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task UpdateAsync() |
||||
|
{ |
||||
|
var updateProjectDto = new UpdateProjectDto |
||||
|
{ |
||||
|
Name = "ABP vNext", |
||||
|
Format = "md", |
||||
|
DefaultDocumentName = "index", |
||||
|
NavigationDocumentName = "docs-nav.json", |
||||
|
|
||||
|
MinimumVersion = "1", |
||||
|
MainWebsiteUrl = "abp.io", |
||||
|
LatestVersionBranchName = "", |
||||
|
ExtraProperties = new Dictionary<string, object>() |
||||
|
}; |
||||
|
updateProjectDto.ExtraProperties.Add("test", "test"); |
||||
|
|
||||
|
var projectDto = await _projectAdminAppService.UpdateAsync(_testData.PorjectId, updateProjectDto); |
||||
|
|
||||
|
|
||||
|
projectDto.ShouldNotBeNull(); |
||||
|
projectDto.Name.ShouldBe(updateProjectDto.Name); |
||||
|
|
||||
|
projectDto.Format.ShouldBe(updateProjectDto.Format); |
||||
|
projectDto.DefaultDocumentName.ShouldBe(updateProjectDto.DefaultDocumentName); |
||||
|
projectDto.NavigationDocumentName.ShouldBe(updateProjectDto.NavigationDocumentName); |
||||
|
projectDto.MinimumVersion.ShouldBe(updateProjectDto.MinimumVersion); |
||||
|
projectDto.MainWebsiteUrl.ShouldBe(updateProjectDto.MainWebsiteUrl); |
||||
|
projectDto.LatestVersionBranchName.ShouldBe(updateProjectDto.LatestVersionBranchName); |
||||
|
projectDto.ExtraProperties.ShouldContainKey("test"); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task DeleteAsync() |
||||
|
{ |
||||
|
(await _projectRepository.GetAsync(_testData.PorjectId)).ShouldNotBeNull(); |
||||
|
|
||||
|
await _projectAdminAppService.DeleteAsync(_testData.PorjectId); |
||||
|
|
||||
|
(await _projectRepository.GetListAsync()).ShouldBeEmpty(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Docs.Documents; |
||||
|
using Volo.Docs.FileSystem.Documents; |
||||
|
using Volo.Docs.GitHub.Documents; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public class DocumentStoreFactory_Tests : DocsDomainTestBase |
||||
|
{ |
||||
|
private readonly IDocumentStoreFactory _documentStoreFactory; |
||||
|
|
||||
|
public DocumentStoreFactory_Tests() |
||||
|
{ |
||||
|
_documentStoreFactory = GetRequiredService<IDocumentStoreFactory>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Create() |
||||
|
{ |
||||
|
_documentStoreFactory.Create(GithubDocumentStore.Type).GetType().ShouldBe(typeof(GithubDocumentStore)); |
||||
|
_documentStoreFactory.Create(FileSystemDocumentStore.Type).GetType().ShouldBe(typeof(FileSystemDocumentStore)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using Shouldly; |
||||
|
using Volo.Docs.Projects; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public class Project_Tests : DocsDomainTestBase |
||||
|
{ |
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetName(string name) |
||||
|
{ |
||||
|
var project = new Project(Guid.NewGuid(), "ABP vNext", "ABP", "Github", "md", "index", |
||||
|
"docs-nav.json"); |
||||
|
project.SetName(name); |
||||
|
project.Name.ShouldBe(name); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetFormat(string format) |
||||
|
{ |
||||
|
var project = new Project(Guid.NewGuid(), "ABP vNext", "ABP", "Github", "md", "index", |
||||
|
"docs-nav.json"); |
||||
|
project.SetFormat(format); |
||||
|
project.Format.ShouldBe(format); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetNavigationDocumentName(string navigationDocumentName) |
||||
|
{ |
||||
|
var project = new Project(Guid.NewGuid(), "ABP vNext", "ABP", "Github", "md", "index", |
||||
|
"docs-nav.json"); |
||||
|
project.SetNavigationDocumentName(navigationDocumentName); |
||||
|
project.NavigationDocumentName.ShouldBe(navigationDocumentName); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("aaa")] |
||||
|
[InlineData("bbb")] |
||||
|
public void SetDefaultDocumentName(string defaultDocumentName) |
||||
|
{ |
||||
|
var project = new Project(Guid.NewGuid(), "ABP vNext", "ABP", "Github", "md", "index", |
||||
|
"docs-nav.json"); |
||||
|
project.SetDefaultDocumentName(defaultDocumentName); |
||||
|
project.DefaultDocumentName.ShouldBe(defaultDocumentName); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Volo.Docs.EntityFrameworkCore |
||||
|
{ |
||||
|
public class ProjectRepository_Tests : ProjectRepository_Tests<DocsEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,8 +1,10 @@ |
|||||
using Volo.Abp.DependencyInjection; |
using System; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
namespace Volo.Docs |
namespace Volo.Docs |
||||
{ |
{ |
||||
public class DocsTestData : ISingletonDependency |
public class DocsTestData : ISingletonDependency |
||||
{ |
{ |
||||
|
public Guid PorjectId { get; } = Guid.NewGuid(); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Docs.Projects; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.Docs |
||||
|
{ |
||||
|
public abstract class ProjectRepository_Tests<TStartupModule> : DocsTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
|
||||
|
protected readonly IProjectRepository _projectRepository; |
||||
|
|
||||
|
protected ProjectRepository_Tests() |
||||
|
{ |
||||
|
_projectRepository = GetRequiredService<IProjectRepository>(); ; |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetListAsync() |
||||
|
{ |
||||
|
var projects = await _projectRepository.GetListAsync(); |
||||
|
|
||||
|
projects.ShouldNotBeNull(); |
||||
|
projects.Count.ShouldBe(1); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetTotalProjectCount() |
||||
|
{ |
||||
|
var count = await _projectRepository.GetTotalProjectCount(); |
||||
|
|
||||
|
count.ShouldBe(1); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task GetByShortNameAsync() |
||||
|
{ |
||||
|
var project = await _projectRepository.GetByShortNameAsync("ABP"); |
||||
|
|
||||
|
project.ShouldNotBeNull(); |
||||
|
project.ShortName.ShouldBe("ABP"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue