mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-02-15 21:06:32 +08:00
ru
This commit is contained in:
@@ -19,18 +19,11 @@ namespace OpenAuth.UnitTest
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
//注册数据库基础操作和工作单元
|
||||
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
|
||||
builder.RegisterType(typeof(UnitWork)).As(typeof(IUnitWork));
|
||||
|
||||
//注册WebConfig中的配置
|
||||
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
|
||||
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>)).PropertiesAutowired();
|
||||
builder.RegisterType(typeof(UnitWork)).As(typeof(IUnitWork)).PropertiesAutowired();
|
||||
|
||||
//注册app层
|
||||
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserManagerApp)));
|
||||
|
||||
//注册领域服务
|
||||
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AuthoriseService)))
|
||||
.Where(u => u.Namespace == "OpenAuth.Domain.Service");
|
||||
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserManagerApp))).PropertiesAutowired();
|
||||
|
||||
_container = builder.Build();
|
||||
DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain.Service;
|
||||
using OpenAuth.Repository;
|
||||
|
||||
@@ -12,13 +13,19 @@ namespace OpenAuth.UnitTest
|
||||
/// 测试用户授权服务
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TestAuthen
|
||||
public class TestAuthen :TestBase
|
||||
{
|
||||
private AuthorizeApp app;
|
||||
|
||||
public TestAuthen()
|
||||
{
|
||||
app = AutofacExt.GetFromFac<AuthorizeApp>();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMethod1()
|
||||
{
|
||||
AuthoriseFactory factory = new AuthoriseFactory( );
|
||||
var service= factory.Create("System");
|
||||
var service= app.Create("System");
|
||||
|
||||
var modules = service.Modules;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user