Browse Source

Revised basic ASP.NETCore-integrated tests.

pull/96/head
Halil İbrahim Kalkan 9 years ago
parent
commit
5ad5a6859c
  1. 3
      test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo.Abp.AspNetCore.MultiTenancy.Tests.csproj
  2. 8
      test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs
  3. 6
      test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/Startup.cs
  4. 9
      test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancyTestBase.cs
  5. 3
      test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_Tests.cs
  6. 6
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj
  7. 25
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/AppModule.cs
  8. 13
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs
  9. 20
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/Startup.cs
  10. 9
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMultiTenancyTestBase.cs
  11. 20
      test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs
  12. 2
      test/Volo.Abp.AspNetCore.Tests/Volo.Abp.AspNetCore.Tests.csproj
  13. 3
      test/Volo.Abp.AspNetCore.Tests/Volo/Abp/AspNetCore/AppTestBase.cs

3
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo.Abp.AspNetCore.MultiTenancy.Tests.csproj

@ -12,9 +12,8 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.MultiTenancy\Volo.Abp.AspNetCore.MultiTenancy.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.TestBase\Volo.Abp.AspNetCore.TestBase.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Tests\Volo.Abp.AspNetCore.Tests.csproj" />
</ItemGroup>
<ItemGroup>

8
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppModule.cs

@ -17,6 +17,14 @@ namespace Volo.Abp.AspNetCore.App
)]
public class AppModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.Configure<MultiTenancyOptions>(options =>
{
options.AddDomainTenantResolver("{0}.abp.io");
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();

6
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/Startup.cs

@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.AspNetCore.App
{
@ -11,11 +10,6 @@ namespace Volo.Abp.AspNetCore.App
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<AppModule>();
services.Configure<MultiTenancyOptions>(options =>
{
options.AddDomainTenantResolver("{0}.abp.io");
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

9
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancyTestBase.cs

@ -0,0 +1,9 @@
using Volo.Abp.AspNetCore.App;
namespace Volo.Abp.AspNetCore.MultiTenancy
{
public abstract class AspNetCoreMultiTenancyTestBase : AbpAspNetCoreTestBase<Startup>
{
}
}

3
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_Tests.cs

@ -6,14 +6,13 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using Shouldly;
using Volo.Abp.AspNetCore.App;
using Volo.Abp.MultiTenancy;
using Volo.Abp.MultiTenancy.ConfigurationStore;
using Xunit;
namespace Volo.Abp.AspNetCore.MultiTenancy
{
public class AspNetCoreMultiTenancy_Tests : AppTestBase
public class AspNetCoreMultiTenancy_Tests : AspNetCoreMultiTenancyTestBase
{
private readonly Guid _testTenantId = Guid.NewGuid();
private readonly string _testTenantName = "acme";

6
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo.Abp.AspNetCore.Mvc.Tests.csproj

@ -16,12 +16,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Volo\Abp\AspNetCore\Mvc\" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Tests\Volo.Abp.AspNetCore.Tests.csproj" />
</ItemGroup>
</Project>

25
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/AppModule.cs

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AspNetCore.TestBase;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.App
{
[DependsOn(
typeof(AbpAspNetCoreTestBaseModule)
)]
public class AppModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseMvcWithDefaultRoute();
}
}
}

13
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/SimpleController.cs

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
namespace Volo.Abp.AspNetCore.App
{
public class SimpleController : AbpController
{
public ActionResult Index()
{
return Content("Index-Result");
}
}
}

20
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/App/Startup.cs

@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Volo.Abp.AspNetCore.App
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<AppModule>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}
}

9
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AspNetCoreMultiTenancyTestBase.cs

@ -0,0 +1,9 @@
using Volo.Abp.AspNetCore.App;
namespace Volo.Abp.AspNetCore.Mvc
{
public abstract class AspNetCoreMvcTestBase : AbpAspNetCoreTestBase<Startup>
{
}
}

20
test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/SimpleController_Tests.cs

@ -0,0 +1,20 @@
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.AspNetCore.App;
using Xunit;
namespace Volo.Abp.AspNetCore.Mvc
{
public class SimpleController_Tests : AspNetCoreMvcTestBase
{
[Fact]
public async Task ActionResult_Return_Type_ContentResult_Return_Value()
{
var result = await GetResponseAsStringAsync(
GetUrl<SimpleController>(nameof(SimpleController.Index))
);
result.ShouldBe("Index-Result");
}
}
}

2
test/Volo.Abp.AspNetCore.Tests/Volo.Abp.AspNetCore.Tests.csproj

@ -16,8 +16,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore.TestBase\Volo.Abp.AspNetCore.TestBase.csproj" />
<ProjectReference Include="..\AbpTestBase\AbpTestBase.csproj" />
<ProjectReference Include="..\..\src\Volo.Abp.AspNetCore\Volo.Abp.AspNetCore.csproj" />
</ItemGroup>
</Project>

3
test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/App/AppTestBase.cs → test/Volo.Abp.AspNetCore.Tests/Volo/Abp/AspNetCore/AppTestBase.cs

@ -8,7 +8,8 @@ using Volo.Abp.AspNetCore.TestBase;
namespace Volo.Abp.AspNetCore.App
{
public abstract class AppTestBase : AbpAspNetCoreIntegratedTestBase<Startup>
public abstract class AbpAspNetCoreTestBase<TStartup> : AbpAspNetCoreIntegratedTestBase<TStartup>
where TStartup : class
{
protected virtual async Task<T> GetResponseAsObjectAsync<T>(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK)
{
Loading…
Cancel
Save