Browse Source

[fix]移除 test 项目

master
rongguo.jia 2 years ago
parent
commit
0a758e278b
  1. 37
      WebApiService/Win_in.Sfs.Scp.WebApi.sln
  2. 33
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/Samples/SampleAppServiceTests.cs
  3. 7
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/WebApiApplicationTestBase.cs
  4. 13
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/WebApiApplicationTestModule.cs
  5. 19
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/Win_in.Sfs.Scp.WebApi.Application.Tests.csproj
  6. 45
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/Samples/SampleDomainTests.cs
  7. 7
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/WebApiDomainTestBase.cs
  8. 13
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/WebApiDomainTestModule.cs
  9. 18
      WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/Win_in.Sfs.Scp.WebApi.Domain.Tests.csproj
  10. 44
      WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs
  11. 9
      WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/WebApiEntityFrameworkCoreTestBase.cs
  12. 62
      WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/WebApiEntityFrameworkCoreTestModule.cs
  13. 20
      WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests.csproj
  14. 26
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs
  15. 37
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs
  16. 26
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/Program.cs
  17. 30
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/WebApiConsoleApiClientModule.cs
  18. 31
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp.csproj
  19. 18
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/appsettings.json
  20. 2
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json
  21. 43
      WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/Security/FakeCurrentPrincipalAccessor.cs
  22. 61
      WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestBase.cs
  23. 62
      WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestBaseModule.cs
  24. 16
      WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestDataSeedContributor.cs
  25. 26
      WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/Win_in.Sfs.Scp.WebApi.TestBase.csproj

37
WebApiService/Win_in.Sfs.Scp.WebApi.sln

@ -11,10 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Entit
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA9AC87F-097E-4F15-8393-4BC07735A5B0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{04DBDB01-70F4-4E06-B468-8F87850B22BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Application.Tests", "test\Win_in.Sfs.Scp.WebApi.Application.Tests\Win_in.Sfs.Scp.WebApi.Application.Tests.csproj", "{50B2631D-129C-47B3-A587-029CCD6099BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Domain.Shared", "src\Win_in.Sfs.Scp.WebApi.Domain.Shared\Win_in.Sfs.Scp.WebApi.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Application.Contracts", "src\Win_in.Sfs.Scp.WebApi.Application.Contracts\Win_in.Sfs.Scp.WebApi.Application.Contracts.csproj", "{520659C8-C734-4298-A3DA-B539DB9DFC0B}"
@ -23,14 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.HttpA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.HttpApi.Client", "src\Win_in.Sfs.Scp.WebApi.HttpApi.Client\Win_in.Sfs.Scp.WebApi.HttpApi.Client.csproj", "{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests", "test\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests.csproj", "{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.TestBase", "test\Win_in.Sfs.Scp.WebApi.TestBase\Win_in.Sfs.Scp.WebApi.TestBase.csproj", "{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Domain.Tests", "test\Win_in.Sfs.Scp.WebApi.Domain.Tests\Win_in.Sfs.Scp.WebApi.Domain.Tests.csproj", "{E512F4D9-9375-480F-A2F6-A46509F9D824}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp", "test\Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp\Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp.csproj", "{EF480016-9127-4916-8735-D2466BDBC582}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.DbMigrator", "src\Win_in.Sfs.Scp.WebApi.DbMigrator\Win_in.Sfs.Scp.WebApi.DbMigrator.csproj", "{AA94D832-1CCC-4715-95A9-A483F23A1A5D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.HttpApi.Host", "src\Win_in.Sfs.Scp.WebApi.HttpApi.Host\Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj", "{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}"
@ -73,10 +61,6 @@ Global
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.Build.0 = Release|Any CPU
{50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50B2631D-129C-47B3-A587-029CCD6099BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50B2631D-129C-47B3-A587-029CCD6099BC}.Release|Any CPU.Build.0 = Release|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -93,22 +77,6 @@ Global
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.Build.0 = Release|Any CPU
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.Build.0 = Release|Any CPU
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Release|Any CPU.Build.0 = Release|Any CPU
{E512F4D9-9375-480F-A2F6-A46509F9D824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E512F4D9-9375-480F-A2F6-A46509F9D824}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E512F4D9-9375-480F-A2F6-A46509F9D824}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E512F4D9-9375-480F-A2F6-A46509F9D824}.Release|Any CPU.Build.0 = Release|Any CPU
{EF480016-9127-4916-8735-D2466BDBC582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF480016-9127-4916-8735-D2466BDBC582}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF480016-9127-4916-8735-D2466BDBC582}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF480016-9127-4916-8735-D2466BDBC582}.Release|Any CPU.Build.0 = Release|Any CPU
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -149,15 +117,10 @@ Global
{554AD327-6DBA-4F8F-96F8-81CE7A0C863F} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{1A94A50E-06DC-43C1-80B5-B662820EC3EB} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{C956DD76-69C8-4A9C-83EA-D17DF83340FD} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{42F719ED-8413-4895-B5B4-5AB56079BC66} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{520659C8-C734-4298-A3DA-B539DB9DFC0B} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{91853F21-9CD9-4132-BC29-A7D5D84FFFE7} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{EF480016-9127-4916-8735-D2466BDBC582} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{AA94D832-1CCC-4715-95A9-A483F23A1A5D} = {A79A01B2-9532-4C6B-880F-193251F3B9F3}
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {44A92E7C-E2FC-4F37-AF3D-6B7213EF54FE}
{3EE98133-3E7A-4B14-A515-12CB039A9EED} = {925EA68F-25D1-444F-A79B-EB9BF754EC3C}

33
WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/Samples/SampleAppServiceTests.cs

@ -1,33 +0,0 @@
using Shouldly;
using System.Threading.Tasks;
using Volo.Abp.Identity;
using Xunit;
namespace Win_in.Sfs.Scp.WebApi.Samples
{
/* This is just an example test class.
* Normally, you don't test code of the modules you are using
* (like IIdentityUserAppService here).
* Only test your own application services.
*/
public class SampleAppServiceTests : WebApiApplicationTestBase
{
private readonly IIdentityUserAppService _userAppService;
public SampleAppServiceTests()
{
_userAppService = GetRequiredService<IIdentityUserAppService>();
}
[Fact]
public async Task Initial_Data_Should_Contain_Admin_User()
{
//Act
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput());
//Assert
result.TotalCount.ShouldBeGreaterThan(0);
result.Items.ShouldContain(u => u.UserName == "admin");
}
}
}

7
WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/WebApiApplicationTestBase.cs

@ -1,7 +0,0 @@
namespace Win_in.Sfs.Scp.WebApi
{
public abstract class WebApiApplicationTestBase : WebApiTestBase<WebApiApplicationTestModule>
{
}
}

13
WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/WebApiApplicationTestModule.cs

@ -1,13 +0,0 @@
using Volo.Abp.Modularity;
namespace Win_in.Sfs.Scp.WebApi
{
[DependsOn(
typeof(WebApiApplicationModule),
typeof(WebApiDomainTestModule)
)]
public class WebApiApplicationTestModule : AbpModule
{
}
}

19
WebApiService/test/Win_in.Sfs.Scp.WebApi.Application.Tests/Win_in.Sfs.Scp.WebApi.Application.Tests.csproj

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Win_in.Sfs.Scp.WebApi.Application\Win_in.Sfs.Scp.WebApi.Application.csproj" />
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.Domain.Tests\Win_in.Sfs.Scp.WebApi.Domain.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
</ItemGroup>
</Project>

45
WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/Samples/SampleDomainTests.cs

@ -1,45 +0,0 @@
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Identity;
using Xunit;
namespace Win_in.Sfs.Scp.WebApi.Samples
{
/* This is just an example test class.
* Normally, you don't test code of the modules you are using
* (like IdentityUserManager here).
* Only test your own domain services.
*/
public class SampleDomainTests : WebApiDomainTestBase
{
private readonly IIdentityUserRepository _identityUserRepository;
private readonly IdentityUserManager _identityUserManager;
public SampleDomainTests()
{
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
_identityUserManager = GetRequiredService<IdentityUserManager>();
}
[Fact]
public async Task Should_Set_Email_Of_A_User()
{
IdentityUser adminUser;
/* Need to manually start Unit Of Work because
* FirstOrDefaultAsync should be executed while db connection / context is available.
*/
await WithUnitOfWorkAsync(async () =>
{
adminUser = await _identityUserRepository
.FindByNormalizedUserNameAsync("ADMIN");
await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
await _identityUserRepository.UpdateAsync(adminUser);
});
adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
adminUser.Email.ShouldBe("newemail@abp.io");
}
}
}

7
WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/WebApiDomainTestBase.cs

@ -1,7 +0,0 @@
namespace Win_in.Sfs.Scp.WebApi
{
public abstract class WebApiDomainTestBase : WebApiTestBase<WebApiDomainTestModule>
{
}
}

13
WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/WebApiDomainTestModule.cs

@ -1,13 +0,0 @@
using Win_in.Sfs.Scp.WebApi.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace Win_in.Sfs.Scp.WebApi
{
[DependsOn(
typeof(WebApiEntityFrameworkCoreTestModule)
)]
public class WebApiDomainTestModule : AbpModule
{
}
}

18
WebApiService/test/Win_in.Sfs.Scp.WebApi.Domain.Tests/Win_in.Sfs.Scp.WebApi.Domain.Tests.csproj

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
</ItemGroup>
</Project>

44
WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs

@ -1,44 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Shouldly;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Xunit;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Samples
{
/* This is just an example test class.
* Normally, you don't test ABP framework code
* (like default AppUser repository IRepository<AppUser, Guid> here).
* Only test your custom repository methods.
*/
public class SampleRepositoryTests : WebApiEntityFrameworkCoreTestBase
{
private readonly IRepository<IdentityUser, Guid> _appUserRepository;
public SampleRepositoryTests()
{
_appUserRepository = GetRequiredService<IRepository<IdentityUser, Guid>>();
}
[Fact]
public async Task Should_Query_AppUser()
{
/* Need to manually start Unit Of Work because
* FirstOrDefaultAsync should be executed while db connection / context is available.
*/
await WithUnitOfWorkAsync(async () =>
{
//Act
var adminUser = await (await _appUserRepository.GetQueryableAsync())
.Where(u => u.UserName == "admin")
.FirstOrDefaultAsync();
//Assert
adminUser.ShouldNotBeNull();
});
}
}
}

9
WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/WebApiEntityFrameworkCoreTestBase.cs

@ -1,9 +0,0 @@
using Volo.Abp;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
{
public abstract class WebApiEntityFrameworkCoreTestBase : WebApiTestBase<WebApiEntityFrameworkCoreTestModule>
{
}
}

62
WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/EntityFrameworkCore/WebApiEntityFrameworkCoreTestModule.cs

@ -1,62 +0,0 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.Modularity;
namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore
{
[DependsOn(
typeof(WebApiEntityFrameworkCoreModule),
typeof(WebApiTestBaseModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class WebApiEntityFrameworkCoreTestModule : AbpModule
{
private SqliteConnection _sqliteConnection;
public override void ConfigureServices(ServiceConfigurationContext context)
{
ConfigureInMemorySqlite(context.Services);
}
private void ConfigureInMemorySqlite(IServiceCollection services)
{
_sqliteConnection = CreateDatabaseAndGetConnection();
services.Configure<AbpDbContextOptions>(options =>
{
options.Configure(context =>
{
context.DbContextOptions.UseSqlite(_sqliteConnection);
});
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_sqliteConnection.Dispose();
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<WebApiDbContext>()
.UseSqlite(connection)
.Options;
using (var context = new WebApiDbContext(options))
{
context.GetService<IRelationalDatabaseCreator>().CreateTables();
}
return connection;
}
}
}

20
WebApiService/test/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.Tests.csproj

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore\Win_in.Sfs.Scp.WebApi.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.TestBase\Win_in.Sfs.Scp.WebApi.TestBase.csproj" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="4.4.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
</ItemGroup>
</Project>

26
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs

@ -1,26 +0,0 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;
namespace Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp
{
public class ClientDemoService : ITransientDependency
{
private readonly IProfileAppService _profileAppService;
public ClientDemoService(IProfileAppService profileAppService)
{
_profileAppService = profileAppService;
}
public async Task RunAsync()
{
var output = await _profileAppService.GetAsync();
Console.WriteLine($"UserName : {output.UserName}");
Console.WriteLine($"Email : {output.Email}");
Console.WriteLine($"Name : {output.Name}");
Console.WriteLine($"Surname : {output.Surname}");
}
}
}

37
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs

@ -1,37 +0,0 @@
using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
namespace Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp
{
public class ConsoleTestAppHostedService : IHostedService
{
private readonly IConfiguration _configuration;
public ConsoleTestAppHostedService(IConfiguration configuration)
{
_configuration = configuration;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<WebApiConsoleApiClientModule>(options =>
{
options.Services.ReplaceConfiguration(_configuration);
}))
{
application.Initialize();
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
await demo.RunAsync();
application.Shutdown();
}
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
}

26
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/Program.cs

@ -1,26 +0,0 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp
{
class Program
{
static async Task Main(string[] args)
{
await CreateHostBuilder(args).RunConsoleAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(build =>
{
build.AddJsonFile("appsettings.secrets.json", optional: true);
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<ConsoleTestAppHostedService>();
});
}
}

30
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/WebApiConsoleApiClientModule.cs

@ -1,30 +0,0 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.IdentityModel;
using Volo.Abp.Modularity;
namespace Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp
{
[DependsOn(
typeof(WebApiHttpApiClientModule),
typeof(AbpHttpClientIdentityModelModule),
typeof(WebApiApplicationContractsModule)
)]
public class WebApiConsoleApiClientModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpHttpClientBuilderOptions>(options =>
{
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
{
clientBuilder.AddTransientHttpErrorPolicy(
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
);
});
});
}
}
}

31
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp.csproj

@ -1,31 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<Content Include="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="appsettings.secrets.json" />
<Content Include="appsettings.secrets.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="4.4.2" />
<ProjectReference Include="..\..\src\Win_in.Sfs.Scp.WebApi.HttpApi.Client\Win_in.Sfs.Scp.WebApi.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.*" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.*" />
</ItemGroup>
</Project>

18
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/appsettings.json

@ -1,18 +0,0 @@
{
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44359"
}
},
"IdentityClients": {
"Default": {
"GrantType": "password",
"ClientId": "WebApi_App",
"ClientSecret": "1q2w3e*",
"UserName": "admin",
"UserPassword": "1q2w3E*",
"Authority": "https://localhost:44359",
"Scope": "WebApi"
}
}
}

2
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json

@ -1,2 +0,0 @@
{
}

43
WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/Security/FakeCurrentPrincipalAccessor.cs

@ -1,43 +0,0 @@
using System.Collections.Generic;
using System.Security.Claims;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Claims;
namespace Win_in.Sfs.Scp.WebApi.Security
{
[Dependency(ReplaceServices = true)]
public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor
{
protected override ClaimsPrincipal GetClaimsPrincipal()
{
return GetPrincipal();
}
private ClaimsPrincipal _principal;
private ClaimsPrincipal GetPrincipal()
{
if (_principal == null)
{
lock (this)
{
if (_principal == null)
{
_principal = new ClaimsPrincipal(
new ClaimsIdentity(
new List<Claim>
{
new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
new Claim(AbpClaimTypes.UserName,"admin"),
new Claim(AbpClaimTypes.Email,"admin@abp.io")
}
)
);
}
}
}
return _principal;
}
}
}

61
WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestBase.cs

@ -1,61 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Volo.Abp.Testing;
namespace Win_in.Sfs.Scp.WebApi
{
/* All test classes are derived from this class, directly or indirectly.
*/
public abstract class WebApiTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
where TStartupModule : IAbpModule
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
protected virtual Task WithUnitOfWorkAsync(Func<Task> func)
{
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
}
protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func<Task> action)
{
using (var scope = ServiceProvider.CreateScope())
{
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
using (var uow = uowManager.Begin(options))
{
await action();
await uow.CompleteAsync();
}
}
}
protected virtual Task<TResult> WithUnitOfWorkAsync<TResult>(Func<Task<TResult>> func)
{
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
}
protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func)
{
using (var scope = ServiceProvider.CreateScope())
{
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
using (var uow = uowManager.Begin(options))
{
var result = await func();
await uow.CompleteAsync();
return result;
}
}
}
}
}

62
WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestBaseModule.cs

@ -1,62 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Authorization;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Data;
using Volo.Abp.IdentityServer;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace Win_in.Sfs.Scp.WebApi
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpTestBaseModule),
typeof(AbpAuthorizationModule),
typeof(WebApiDomainModule)
)]
public class WebApiTestBaseModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<AbpIdentityServerBuilderOptions>(options =>
{
options.AddDeveloperSigningCredential = false;
});
PreConfigure<IIdentityServerBuilder>(identityServerBuilder =>
{
identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString());
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpBackgroundJobOptions>(options =>
{
options.IsJobExecutionEnabled = false;
});
context.Services.AddAlwaysAllowAuthorization();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
SeedTestData(context);
}
private static void SeedTestData(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(async () =>
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}
}

16
WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/WebApiTestDataSeedContributor.cs

@ -1,16 +0,0 @@
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
namespace Win_in.Sfs.Scp.WebApi
{
public class WebApiTestDataSeedContributor : IDataSeedContributor, ITransientDependency
{
public Task SeedAsync(DataSeedContext context)
{
/* Seed additional test data... */
return Task.CompletedTask;
}
}
}

26
WebApiService/test/Win_in.Sfs.Scp.WebApi.TestBase/Win_in.Sfs.Scp.WebApi.TestBase.csproj

@ -1,26 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.TestBase" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Authorization" Version="4.4.2" />
<ProjectReference Include="..\..\src\Win_in.Sfs.Scp.WebApi.Domain\Win_in.Sfs.Scp.WebApi.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NSubstitute" Version="4.2.2" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>
</Project>
Loading…
Cancel
Save