mirror of https://github.com/abpframework/abp.git
13 changed files with 256 additions and 6 deletions
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.TestBase |
|||
{ |
|||
public class AbpIntegratedTest<TStartupModule> : IDisposable |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
|
|||
protected AbpApplication Application { get; } |
|||
|
|||
protected IServiceProvider ServiceProvider => Application.ServiceProvider; |
|||
|
|||
public AbpIntegratedTest() |
|||
{ |
|||
var services = CreateServiceCollection(); |
|||
Application = AbpApplication.Create<TStartupModule>(services); |
|||
var serviceProvider = CreateServiceProvider(services); |
|||
Application.Initialize(serviceProvider); |
|||
} |
|||
|
|||
protected virtual IServiceCollection CreateServiceCollection() |
|||
{ |
|||
return new ServiceCollection(); |
|||
} |
|||
|
|||
protected virtual IServiceProvider CreateServiceProvider(IServiceCollection services) |
|||
{ |
|||
return services.BuildServiceProvider(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
Application.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Volo.Abp.TestBase")] |
|||
[assembly: AssemblyTrademark("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("8cecceaf-f0d8-4257-96ba-eacf4763af42")] |
|||
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>8cecceaf-f0d8-4257-96ba-eacf4763af42</ProjectGuid> |
|||
<RootNamespace>Volo.Abp.TestBase</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,14 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
|
|||
"dependencies": { |
|||
"NETStandard.Library": "1.6.1", |
|||
"Volo.Abp": "1.0.0-*" |
|||
}, |
|||
|
|||
"frameworks": { |
|||
"netstandard1.6": { |
|||
"imports": "dnxcore50" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>e6e2467c-184a-4a0a-929f-932d5097953e</ProjectGuid> |
|||
<RootNamespace> |
|||
</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,27 @@ |
|||
using AbpDesk.EntityFrameworkCore; |
|||
using AbpDesk.Tickets; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.TestBase; |
|||
|
|||
namespace AbpDesk |
|||
{ |
|||
public abstract class AbpDeskApplicationTestBase : AbpIntegratedTest<AbpDeskApplicationTestModule> |
|||
{ |
|||
protected AbpDeskApplicationTestBase() |
|||
{ |
|||
SeedTestData(); |
|||
} |
|||
|
|||
protected virtual void SeedTestData() |
|||
{ |
|||
using (var scope = ServiceProvider.CreateScope()) |
|||
{ |
|||
var dbContext = scope.ServiceProvider.GetRequiredService<AbpDeskDbContext>(); |
|||
|
|||
dbContext.Set<Ticket>().Add(new Ticket("My test ticket 1 title", "My test ticket 1 body")); |
|||
|
|||
dbContext.SaveChanges(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using AbpDesk.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace AbpDesk |
|||
{ |
|||
[DependsOn(typeof(AbpDeskApplicationModule), typeof(AbpDeskEntityFrameworkCoreModule))] |
|||
public class AbpDeskApplicationTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddEntityFrameworkInMemoryDatabase(); |
|||
services.AddDbContext<AbpDeskDbContext>(options => |
|||
{ |
|||
options.UseInMemoryDatabase(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace AbpDesk.Tickets |
|||
{ |
|||
public class TicketAppService_Tests : AbpDeskApplicationTestBase |
|||
{ |
|||
private readonly ITicketAppService _ticketAppService; |
|||
|
|||
public TicketAppService_Tests() |
|||
{ |
|||
_ticketAppService = ServiceProvider.GetRequiredService<ITicketAppService>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetAll_Test() |
|||
{ |
|||
//Act
|
|||
|
|||
var result = _ticketAppService.GetAll(); |
|||
|
|||
//Assert
|
|||
|
|||
result.Items.Count.ShouldBeGreaterThan(0); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("AbpDesk.Application.Tests")] |
|||
[assembly: AssemblyTrademark("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("e6e2467c-184a-4a0a-929f-932d5097953e")] |
|||
@ -0,0 +1,24 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
|
|||
"testRunner": "xunit", |
|||
|
|||
"dependencies": { |
|||
"AbpDesk.Application": "1.0.0-*", |
|||
"AbpDesk.EntityFrameworkCore": "1.0.0-*", |
|||
"AbpTestBase": "1.0.0-*", |
|||
"Microsoft.EntityFrameworkCore.InMemory": "1.1.0", |
|||
"Volo.Abp.TestBase": "1.0.0-*" |
|||
}, |
|||
|
|||
"frameworks": { |
|||
"netcoreapp1.1": { |
|||
"dependencies": { |
|||
"Microsoft.NETCore.App": { |
|||
"type": "platform", |
|||
"version": "1.1.0" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue