You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/test/Volo.Abp.Identity.Tests/Volo/Abp/Identity/AbpIdentityCommonTestBase.cs

39 lines
1.1 KiB

using System;
using System.Linq;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace Volo.Abp.Identity
{
public abstract class AbpIdentityCommonTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
where TStartupModule : IAbpModule
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
protected virtual IdentityUser GetUserAsync(string userName)
{
return UsingDbContext(context => context.Users.FirstOrDefault(u => u.UserName == userName));
}
protected virtual void UsingDbContext(Action<IIdentityDbContext> action)
{
using (var dbContext = GetRequiredService<IIdentityDbContext>())
{
action.Invoke(dbContext);
}
}
protected virtual T UsingDbContext<T>(Func<IIdentityDbContext, T> action)
{
using (var dbContext = GetRequiredService<IIdentityDbContext>())
{
return action.Invoke(dbContext);
}
}
}
}