This commit is contained in:
yubao
2017-11-29 00:48:51 +08:00
parent ead70c2f56
commit c860101747
6 changed files with 32 additions and 60 deletions

View File

@@ -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));

View File

@@ -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;