chore 优化代码
This commit is contained in:
		| @ -5,5 +5,4 @@ namespace KonSoft.Payment; | ||||
| public abstract class PaymentApplicationTestBase<TStartupModule> : PaymentTestBase<TStartupModule> | ||||
|     where TStartupModule : IAbpModule | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -8,5 +8,4 @@ namespace KonSoft.Payment; | ||||
| )] | ||||
| public class PaymentApplicationTestModule : AbpModule | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -1,5 +1,5 @@ | ||||
| using Shouldly; | ||||
| using System.Threading.Tasks; | ||||
| using System.Threading.Tasks; | ||||
| using Shouldly; | ||||
| using Volo.Abp.Identity; | ||||
| using Volo.Abp.Modularity; | ||||
| using Xunit; | ||||
| @ -31,4 +31,4 @@ public abstract class SampleAppServiceTests<TStartupModule> : PaymentApplication | ||||
|         result.TotalCount.ShouldBeGreaterThan(0); | ||||
|         result.Items.ShouldContain(u => u.UserName == "admin"); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -6,5 +6,4 @@ namespace KonSoft.Payment; | ||||
| public abstract class PaymentDomainTestBase<TStartupModule> : PaymentTestBase<TStartupModule> | ||||
|     where TStartupModule : IAbpModule | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -8,5 +8,4 @@ namespace KonSoft.Payment; | ||||
| )] | ||||
| public class PaymentDomainTestModule : AbpModule | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -14,8 +14,8 @@ namespace KonSoft.Payment.Samples; | ||||
| public abstract class SampleDomainTests<TStartupModule> : PaymentDomainTestBase<TStartupModule> | ||||
|     where TStartupModule : IAbpModule | ||||
| { | ||||
|     private readonly IIdentityUserRepository _identityUserRepository; | ||||
|     private readonly IdentityUserManager _identityUserManager; | ||||
|     private readonly IIdentityUserRepository _identityUserRepository; | ||||
|  | ||||
|     protected SampleDomainTests() | ||||
|     { | ||||
| @ -43,4 +43,4 @@ public abstract class SampleDomainTests<TStartupModule> : PaymentDomainTestBase< | ||||
|         adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN"); | ||||
|         adminUser.Email.ShouldBe("newemail@abp.io"); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -6,5 +6,4 @@ namespace KonSoft.Payment.EntityFrameworkCore.Applications; | ||||
| [Collection(PaymentTestConsts.CollectionDefinitionName)] | ||||
| public class EfCoreSampleAppServiceTests : SampleAppServiceTests<PaymentEntityFrameworkCoreTestModule> | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -6,5 +6,4 @@ namespace KonSoft.Payment.EntityFrameworkCore.Domains; | ||||
| [Collection(PaymentTestConsts.CollectionDefinitionName)] | ||||
| public class EfCoreSampleDomainTests : SampleDomainTests<PaymentEntityFrameworkCoreTestModule> | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -5,5 +5,4 @@ namespace KonSoft.Payment.EntityFrameworkCore; | ||||
| [CollectionDefinition(PaymentTestConsts.CollectionDefinitionName)] | ||||
| public class PaymentEntityFrameworkCoreCollection : ICollectionFixture<PaymentEntityFrameworkCoreFixture> | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -1,9 +1,7 @@ | ||||
| using KonSoft.Payment.EntityFrameworkCore; | ||||
| using Xunit; | ||||
| using Xunit; | ||||
|  | ||||
| namespace KonSoft.Payment.EntityFrameworkCore; | ||||
|  | ||||
| public class PaymentEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture<PaymentEntityFrameworkCoreFixture> | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -6,6 +6,5 @@ public class PaymentEntityFrameworkCoreFixture : IDisposable | ||||
| { | ||||
|     public void Dispose() | ||||
|     { | ||||
|  | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,8 +1,5 @@ | ||||
| using Volo.Abp; | ||||
|  | ||||
| namespace KonSoft.Payment.EntityFrameworkCore; | ||||
| namespace KonSoft.Payment.EntityFrameworkCore; | ||||
|  | ||||
| public abstract class PaymentEntityFrameworkCoreTestBase : PaymentTestBase<PaymentEntityFrameworkCoreTestModule> | ||||
| { | ||||
|  | ||||
| } | ||||
| } | ||||
| @ -18,7 +18,7 @@ namespace KonSoft.Payment.EntityFrameworkCore; | ||||
|     typeof(PaymentApplicationTestModule), | ||||
|     typeof(PaymentEntityFrameworkCoreModule), | ||||
|     typeof(AbpEntityFrameworkCoreSqliteModule) | ||||
|     )] | ||||
| )] | ||||
| public class PaymentEntityFrameworkCoreTestModule : AbpModule | ||||
| { | ||||
|     private SqliteConnection? _sqliteConnection; | ||||
| @ -51,10 +51,7 @@ public class PaymentEntityFrameworkCoreTestModule : AbpModule | ||||
|  | ||||
|         services.Configure<AbpDbContextOptions>(options => | ||||
|         { | ||||
|             options.Configure(context => | ||||
|             { | ||||
|                 context.DbContextOptions.UseSqlite(_sqliteConnection); | ||||
|             }); | ||||
|             options.Configure(context => { context.DbContextOptions.UseSqlite(_sqliteConnection); }); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| @ -79,4 +76,4 @@ public class PaymentEntityFrameworkCoreTestModule : AbpModule | ||||
|  | ||||
|         return connection; | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,8 +1,8 @@ | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Shouldly; | ||||
| using System; | ||||
| using System; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Shouldly; | ||||
| using Volo.Abp.Domain.Repositories; | ||||
| using Volo.Abp.Identity; | ||||
| using Xunit; | ||||
| @ -32,13 +32,13 @@ public class SampleRepositoryTests : PaymentEntityFrameworkCoreTestBase | ||||
|          */ | ||||
|         await WithUnitOfWorkAsync(async () => | ||||
|         { | ||||
|                 //Act | ||||
|                 var adminUser = await (await _appUserRepository.GetQueryableAsync()) | ||||
|             //Act | ||||
|             var adminUser = await (await _appUserRepository.GetQueryableAsync()) | ||||
|                 .Where(u => u.UserName == "admin") | ||||
|                 .FirstOrDefaultAsync(); | ||||
|  | ||||
|                 //Assert | ||||
|                 adminUser.ShouldNotBeNull(); | ||||
|             //Assert | ||||
|             adminUser.ShouldNotBeNull(); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -22,4 +22,4 @@ public class ClientDemoService : ITransientDependency | ||||
|         Console.WriteLine($"Name     : {output.Name}"); | ||||
|         Console.WriteLine($"Surname  : {output.Surname}"); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,8 +1,8 @@ | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using Volo.Abp; | ||||
|  | ||||
| namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp; | ||||
| @ -19,10 +19,10 @@ public class ConsoleTestAppHostedService : IHostedService | ||||
|     public async Task StartAsync(CancellationToken cancellationToken) | ||||
|     { | ||||
|         using (var application = await AbpApplicationFactory.CreateAsync<PaymentConsoleApiClientModule>(options => | ||||
|         { | ||||
|            options.Services.ReplaceConfiguration(_configuration); | ||||
|            options.UseAutofac(); | ||||
|         })) | ||||
|                { | ||||
|                    options.Services.ReplaceConfiguration(_configuration); | ||||
|                    options.UseAutofac(); | ||||
|                })) | ||||
|         { | ||||
|             await application.InitializeAsync(); | ||||
|  | ||||
| @ -37,4 +37,4 @@ public class ConsoleTestAppHostedService : IHostedService | ||||
|     { | ||||
|         return Task.CompletedTask; | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -12,7 +12,7 @@ namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp; | ||||
|     typeof(AbpAutofacModule), | ||||
|     typeof(PaymentHttpApiClientModule), | ||||
|     typeof(AbpHttpClientIdentityModelModule) | ||||
|     )] | ||||
| )] | ||||
| public class PaymentConsoleApiClientModule : AbpModule | ||||
| { | ||||
|     public override void PreConfigureServices(ServiceConfigurationContext context) | ||||
| @ -21,10 +21,10 @@ public class PaymentConsoleApiClientModule : AbpModule | ||||
|         { | ||||
|             options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => | ||||
|             { | ||||
|                 clientBuilder.AddTransientHttpErrorPolicy( | ||||
|                     policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) | ||||
|                 clientBuilder.AddTransientHttpErrorPolicy(policyBuilder => | ||||
|                     policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) | ||||
|                 ); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,22 +1,23 @@ | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Hosting; | ||||
|  | ||||
| namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp; | ||||
|  | ||||
| class Program | ||||
| internal class Program | ||||
| { | ||||
|     static async Task Main(string[] args) | ||||
|     private static async Task Main(string[] args) | ||||
|     { | ||||
|         await CreateHostBuilder(args).RunConsoleAsync(); | ||||
|     } | ||||
|  | ||||
|     public static IHostBuilder CreateHostBuilder(string[] args) => | ||||
|         Host.CreateDefaultBuilder(args) | ||||
|     public static IHostBuilder CreateHostBuilder(string[] args) | ||||
|     { | ||||
|         return Host.CreateDefaultBuilder(args) | ||||
|             .AddAppSettingsSecretsJson() | ||||
|             .ConfigureServices((hostContext, services) => | ||||
|             { | ||||
|                 services.AddHostedService<ConsoleTestAppHostedService>(); | ||||
|             }); | ||||
| } | ||||
|     } | ||||
| } | ||||
| @ -3,8 +3,8 @@ using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Volo.Abp; | ||||
| using Volo.Abp.Modularity; | ||||
| using Volo.Abp.Uow; | ||||
| using Volo.Abp.Testing; | ||||
| using Volo.Abp.Uow; | ||||
|  | ||||
| namespace KonSoft.Payment; | ||||
|  | ||||
| @ -43,7 +43,8 @@ public abstract class PaymentTestBase<TStartupModule> : AbpIntegratedTest<TStart | ||||
|         return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); | ||||
|     } | ||||
|  | ||||
|     protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func) | ||||
|     protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, | ||||
|         Func<Task<TResult>> func) | ||||
|     { | ||||
|         using (var scope = ServiceProvider.CreateScope()) | ||||
|         { | ||||
| @ -57,4 +58,4 @@ public abstract class PaymentTestBase<TStartupModule> : AbpIntegratedTest<TStart | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -14,15 +14,12 @@ namespace KonSoft.Payment; | ||||
|     typeof(AbpTestBaseModule), | ||||
|     typeof(AbpAuthorizationModule), | ||||
|     typeof(AbpBackgroundJobsAbstractionsModule) | ||||
|     )] | ||||
| )] | ||||
| public class PaymentTestBaseModule : AbpModule | ||||
| { | ||||
|     public override void ConfigureServices(ServiceConfigurationContext context) | ||||
|     { | ||||
|         Configure<AbpBackgroundJobOptions>(options => | ||||
|         { | ||||
|             options.IsJobExecutionEnabled = false; | ||||
|         }); | ||||
|         Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; }); | ||||
|  | ||||
|         context.Services.AddAlwaysAllowAuthorization(); | ||||
|     } | ||||
| @ -44,4 +41,4 @@ public class PaymentTestBaseModule : AbpModule | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -3,4 +3,4 @@ | ||||
| public static class PaymentTestConsts | ||||
| { | ||||
|     public const string CollectionDefinitionName = "Payment collection"; | ||||
| } | ||||
| } | ||||
| @ -12,4 +12,4 @@ public class PaymentTestDataSeedContributor : IDataSeedContributor, ITransientDe | ||||
|  | ||||
|         return Task.CompletedTask; | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -17,9 +17,9 @@ public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor | ||||
|     { | ||||
|         return 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") | ||||
|             new(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), | ||||
|             new(AbpClaimTypes.UserName, "admin"), | ||||
|             new(AbpClaimTypes.Email, "admin@abp.io") | ||||
|         })); | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user