Browse Source

Created integration test for AbpDesk

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent
commit
c5a59465df
  1. 17
      Volo.Abp.sln
  2. 4
      global.json
  3. 8
      src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskEntityFrameworkCoreModule.cs
  4. 38
      src/Volo.Abp.TestBase/AbpIntegratedTest.cs
  5. 19
      src/Volo.Abp.TestBase/Properties/AssemblyInfo.cs
  6. 21
      src/Volo.Abp.TestBase/Volo.Abp.TestBase.xproj
  7. 14
      src/Volo.Abp.TestBase/project.json
  8. 23
      test/AbpDesk/AbpDesk.Application.Tests/AbpDesk.Application.Tests.xproj
  9. 27
      test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/AbpDeskApplicationTestBase.cs
  10. 20
      test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/AbpDeskApplicationTestModule.cs
  11. 28
      test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/Tickets/TicketAppService_Tests.cs
  12. 19
      test/AbpDesk/AbpDesk.Application.Tests/Properties/AssemblyInfo.cs
  13. 24
      test/AbpDesk/AbpDesk.Application.Tests/project.json

17
Volo.Abp.sln

@ -68,6 +68,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.AspNetCore.Mvc", "
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.ApplicationContracts", "src\Volo.Abp.ApplicationContracts\Volo.Abp.ApplicationContracts.xproj", "{69C72C98-B864-43F7-88B8-19536C7C9B43}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.ApplicationContracts", "src\Volo.Abp.ApplicationContracts\Volo.Abp.ApplicationContracts.xproj", "{69C72C98-B864-43F7-88B8-19536C7C9B43}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AbpDesk", "AbpDesk", "{61708AC8-CE70-4351-9B31-13EA8213D208}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AbpDesk.Application.Tests", "test\AbpDesk\AbpDesk.Application.Tests\AbpDesk.Application.Tests.xproj", "{E6E2467C-184A-4A0A-929F-932D5097953E}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.TestBase", "src\Volo.Abp.TestBase\Volo.Abp.TestBase.xproj", "{8CECCEAF-F0D8-4257-96BA-EACF4763AF42}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -166,6 +172,14 @@ Global
{69C72C98-B864-43F7-88B8-19536C7C9B43}.Debug|Any CPU.Build.0 = Debug|Any CPU {69C72C98-B864-43F7-88B8-19536C7C9B43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69C72C98-B864-43F7-88B8-19536C7C9B43}.Release|Any CPU.ActiveCfg = Release|Any CPU {69C72C98-B864-43F7-88B8-19536C7C9B43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69C72C98-B864-43F7-88B8-19536C7C9B43}.Release|Any CPU.Build.0 = Release|Any CPU {69C72C98-B864-43F7-88B8-19536C7C9B43}.Release|Any CPU.Build.0 = Release|Any CPU
{E6E2467C-184A-4A0A-929F-932D5097953E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6E2467C-184A-4A0A-929F-932D5097953E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6E2467C-184A-4A0A-929F-932D5097953E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6E2467C-184A-4A0A-929F-932D5097953E}.Release|Any CPU.Build.0 = Release|Any CPU
{8CECCEAF-F0D8-4257-96BA-EACF4763AF42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CECCEAF-F0D8-4257-96BA-EACF4763AF42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CECCEAF-F0D8-4257-96BA-EACF4763AF42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CECCEAF-F0D8-4257-96BA-EACF4763AF42}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -199,5 +213,8 @@ Global
{1A1575D7-E57E-4A40-8113-FD01BB1753D5} = {1187F469-0063-4065-9419-A1D956C80145} {1A1575D7-E57E-4A40-8113-FD01BB1753D5} = {1187F469-0063-4065-9419-A1D956C80145}
{3FB342CA-23B6-4795-91EF-C664527C07B7} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {3FB342CA-23B6-4795-91EF-C664527C07B7} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8}
{69C72C98-B864-43F7-88B8-19536C7C9B43} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {69C72C98-B864-43F7-88B8-19536C7C9B43} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8}
{61708AC8-CE70-4351-9B31-13EA8213D208} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{E6E2467C-184A-4A0A-929F-932D5097953E} = {61708AC8-CE70-4351-9B31-13EA8213D208}
{8CECCEAF-F0D8-4257-96BA-EACF4763AF42} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

4
global.json

@ -1,5 +1,5 @@
{ {
"projects": [ "src", "test" ], "projects": [ "src", "test", "src/AbpDesk" ],
"sdk": { "sdk": {
"version": "1.0.0-preview2-003131" "version": "1.0.0-preview2-003131"
} }

8
src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskEntityFrameworkCoreModule.cs

@ -16,10 +16,10 @@ namespace AbpDesk.EntityFrameworkCore
services.AddTransient<IRepository<Ticket, int>, EfCoreRepository<AbpDeskDbContext, Ticket, int>>(); services.AddTransient<IRepository<Ticket, int>, EfCoreRepository<AbpDeskDbContext, Ticket, int>>();
services.AddDbContext<AbpDeskDbContext>(options => //services.AddDbContext<AbpDeskDbContext>(options =>
{ //{
options.UseSqlServer("Server=localhost;Database=AbpDesk;Trusted_Connection=True;"); // options.UseSqlServer("Server=localhost;Database=AbpDesk;Trusted_Connection=True;");
}); //});
} }
} }
} }

38
src/Volo.Abp.TestBase/AbpIntegratedTest.cs

@ -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();
}
}
}

19
src/Volo.Abp.TestBase/Properties/AssemblyInfo.cs

@ -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")]

21
src/Volo.Abp.TestBase/Volo.Abp.TestBase.xproj

@ -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>

14
src/Volo.Abp.TestBase/project.json

@ -0,0 +1,14 @@
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.1",
"Volo.Abp": "1.0.0-*"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}

23
test/AbpDesk/AbpDesk.Application.Tests/AbpDesk.Application.Tests.xproj

@ -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>

27
test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/AbpDeskApplicationTestBase.cs

@ -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();
}
}
}
}

20
test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/AbpDeskApplicationTestModule.cs

@ -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();
});
}
}
}

28
test/AbpDesk/AbpDesk.Application.Tests/AbpDesk/Tickets/TicketAppService_Tests.cs

@ -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);
}
}
}

19
test/AbpDesk/AbpDesk.Application.Tests/Properties/AssemblyInfo.cs

@ -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")]

24
test/AbpDesk/AbpDesk.Application.Tests/project.json

@ -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…
Cancel
Save