Improve the doc module unit test.

pull/988/head
maliming 7 years ago
parent 6671eee1b1
commit cf95f1922d

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

@ -3,15 +3,6 @@ using Volo.Docs.Admin;
namespace Volo.Docs
{
[DependsOn(
typeof(DocsApplicationModule),
typeof(DocsDomainTestModule)
)]
public class DocsApplicationTestModule : AbpModule
{
}
[DependsOn(
typeof(DocsAdminApplicationModule),
typeof(DocsDomainTestModule)

@ -36,7 +36,10 @@ namespace Volo.Docs
[Fact]
public async Task GetVersionsAsync()
{
// TODO: Need to mock WebClient and Octokit components
var versions = await _projectAppService.GetVersionsAsync("ABP");
versions.ShouldNotBeNull();
versions.Items.Count.ShouldBe(1);
versions.Items.ShouldContain(x => x.Name == "0.15.0" && x.DisplayName == "0.15.0");
}
}
}

@ -0,0 +1,7 @@
namespace Volo.Docs
{
public class DocsApplicationTestBase : DocsTestBase<DocsApplicationTestModule>
{
}
}

@ -1,43 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Octokit;
using Volo.Docs.GitHub.Documents;
namespace Volo.Docs
namespace Volo.Docs
{
public abstract class DocsDomainTestBase : DocsTestBase<DocsDomainTestModule>
{
protected override void AfterAddApplication(IServiceCollection services)
{
var repositoryManager = Substitute.For<IGithubRepositoryManager>();
repositoryManager.GetFileRawStringContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns("stringContent");
repositoryManager.GetFileRawByteArrayContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new byte[] { 0x01, 0x02, 0x03 });
repositoryManager.GetReleasesAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new List<Release>
{
new Release("https://api.github.com/repos/abpframework/abp/releases/16293679",
"https://github.com/abpframework/abp/releases/tag/0.15.0",
"https://api.github.com/repos/abpframework/abp/releases/16293679/assets",
"https://uploads.github.com/repos/abpframework/abp/releases/16293679/assets{?name,label}",
16293679,
"0.15.0",
"master",
"0.15.0",
"0.15.0 already release",
false,
false,
DateTimeOffset.Parse("2019-03-22T18:43:58Z"),
DateTimeOffset.Parse("2019-03-22T19:44:25Z"),
null,
"https://api.github.com/repos/abpframework/abp/tarball/0.15.0",
"https://api.github.com/repos/abpframework/abp/zipball/0.15.0",
null)
});
services.AddSingleton(repositoryManager);
}
}
}

@ -1,5 +1,11 @@
using Volo.Abp;
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Octokit;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Docs.GitHub.Documents;
namespace Volo.Docs
{
@ -10,5 +16,36 @@ namespace Volo.Docs
{
options.UseAutofac();
}
protected override void AfterAddApplication(IServiceCollection services)
{
var repositoryManager = Substitute.For<IGithubRepositoryManager>();
repositoryManager.GetFileRawStringContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns("stringContent");
repositoryManager.GetFileRawByteArrayContentAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new byte[] { 0x01, 0x02, 0x03 });
repositoryManager.GetReleasesAsync(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>())
.Returns(new List<Release>
{
new Release("https://api.github.com/repos/abpframework/abp/releases/16293679",
"https://github.com/abpframework/abp/releases/tag/0.15.0",
"https://api.github.com/repos/abpframework/abp/releases/16293679/assets",
"https://uploads.github.com/repos/abpframework/abp/releases/16293679/assets{?name,label}",
16293679,
"0.15.0",
"master",
"0.15.0",
"0.15.0 already release",
false,
false,
DateTimeOffset.Parse("2019-03-22T18:43:58Z"),
DateTimeOffset.Parse("2019-03-22T19:44:25Z"),
null,
"https://api.github.com/repos/abpframework/abp/tarball/0.15.0",
"https://api.github.com/repos/abpframework/abp/zipball/0.15.0",
null)
});
services.AddSingleton(repositoryManager);
}
}
}

Loading…
Cancel
Save