mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-19 07:44:59 +08:00
完善单元测试
This commit is contained in:
parent
5385d4e03e
commit
f001e83c33
@ -24,8 +24,10 @@ using OpenAuth.Repository;
|
|||||||
|
|
||||||
namespace OpenAuth.Mvc
|
namespace OpenAuth.Mvc
|
||||||
{
|
{
|
||||||
internal static class AutofacExt
|
public static class AutofacExt
|
||||||
{
|
{
|
||||||
|
private static IContainer _container;
|
||||||
|
|
||||||
public static void InitAutofac()
|
public static void InitAutofac()
|
||||||
{
|
{
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
@ -61,8 +63,8 @@ namespace OpenAuth.Mvc
|
|||||||
builder.RegisterFilterProvider();
|
builder.RegisterFilterProvider();
|
||||||
|
|
||||||
// Set the dependency resolver to be Autofac.
|
// Set the dependency resolver to be Autofac.
|
||||||
var container = builder.Build();
|
_container = builder.Build();
|
||||||
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
|
DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -71,7 +73,8 @@ namespace OpenAuth.Mvc
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public static T GetFromFac<T>()
|
public static T GetFromFac<T>()
|
||||||
{
|
{
|
||||||
return (T)DependencyResolver.Current.GetService(typeof(T));
|
return _container.Resolve<T>();
|
||||||
|
// return (T)DependencyResolver.Current.GetService(typeof(T));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,3 +34,11 @@ var QueryString = function () {
|
|||||||
}
|
}
|
||||||
return query_string;
|
return query_string;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
$.getUrlParam = function (name) {
|
||||||
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||||||
|
var r = window.location.search.substr(1).match(reg);
|
||||||
|
if (r != null) return unescape(r[2]); return null;
|
||||||
|
}
|
||||||
|
})(jQuery);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<div id="wfdesigner"></div>
|
<div id="wfdesigner"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var schemecode = QueryString["schemeName"];
|
var schemecode = decodeURI(QueryString["schemeName"]);
|
||||||
var inputScheme = $("#schemeName");
|
var inputScheme = $("#schemeName");
|
||||||
var add = schemecode == "" ? true : false;
|
var add = schemecode == "" ? true : false;
|
||||||
if (!add) {
|
if (!add) {
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||||
</configSections>
|
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration" />
|
||||||
|
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
|
||||||
<connectionStrings>
|
<connectionStrings>
|
||||||
<add name="OpenAuthDBContext" connectionString="Data Source=.;Initial Catalog=OpenAuthDB;Persist Security Info=True;User ID=sa;Password=000000;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
|
<add name="OpenAuthDBContext" connectionString="Data Source=.;Initial Catalog=OpenAuthDB;Persist Security Info=True;User ID=sa;Password=000000;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
|
||||||
|
<add name="WorkFlow" connectionString="Data Source=.;Initial Catalog=Workflow.Net;Persist Security Info=True;User ID=sa;Password=000000;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
<log4net>
|
<log4net>
|
||||||
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
|
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||||
@ -27,6 +29,20 @@
|
|||||||
<appender-ref ref="RollingLogFileAppender" />
|
<appender-ref ref="RollingLogFileAppender" />
|
||||||
</root>
|
</root>
|
||||||
</log4net>
|
</log4net>
|
||||||
|
|
||||||
|
<autofac defaultAssembly=" OpenAuth.Repository">
|
||||||
|
<components>
|
||||||
|
<component type=" OpenAuth.Repository.UserRepository" service=" OpenAuth.Domain.Interface.IUserRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.OrgRepository" service="OpenAuth.Domain.Interface.IOrgRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.RoleRepository" service="OpenAuth.Domain.Interface.IRoleRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.ModuleRepository" service="OpenAuth.Domain.Interface.IModuleRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.RelevanceRepository" service="OpenAuth.Domain.Interface.IRelevanceRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.CategoryRepository" service="OpenAuth.Domain.Interface.ICategoryRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.ResourceRepository" service="OpenAuth.Domain.Interface.IResourceRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.StockRepository" service="OpenAuth.Domain.Interface.IStockRepository,OpenAuth.Domain" />
|
||||||
|
<component type=" OpenAuth.Repository.Workflow.WorkflowSchemeRepository" service="OpenAuth.Domain.Interface.IWorkflowSchemeRepository,OpenAuth.Domain" />
|
||||||
|
</components>
|
||||||
|
</autofac>
|
||||||
<entityFramework>
|
<entityFramework>
|
||||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
|
||||||
<parameters>
|
<parameters>
|
||||||
@ -44,6 +60,18 @@
|
|||||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
|
||||||
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
44
OpenAuth.UnitTest/AutofacExt.cs
Normal file
44
OpenAuth.UnitTest/AutofacExt.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Autofac;
|
||||||
|
using Autofac.Configuration;
|
||||||
|
using Autofac.Integration.Mvc;
|
||||||
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.Domain.Interface;
|
||||||
|
using OpenAuth.Domain.Service;
|
||||||
|
using OpenAuth.Repository;
|
||||||
|
|
||||||
|
namespace OpenAuth.UnitTest
|
||||||
|
{
|
||||||
|
public class AutofacExt
|
||||||
|
{
|
||||||
|
private static IContainer _container;
|
||||||
|
|
||||||
|
public static void InitDI()
|
||||||
|
{
|
||||||
|
var builder = new ContainerBuilder();
|
||||||
|
|
||||||
|
//注册数据库基础操作和工作单元
|
||||||
|
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
|
||||||
|
builder.RegisterType(typeof(UnitWork)).As(typeof(IUnitWork));
|
||||||
|
|
||||||
|
//注册WebConfig中的配置
|
||||||
|
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
|
||||||
|
|
||||||
|
//注册app层
|
||||||
|
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserManagerApp)));
|
||||||
|
|
||||||
|
//注册领域服务
|
||||||
|
builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(AuthoriseService)))
|
||||||
|
.Where(u => u.Namespace == "OpenAuth.Domain.Service");
|
||||||
|
|
||||||
|
_container = builder.Build();
|
||||||
|
DependencyResolver.SetResolver(new AutofacDependencyResolver(_container));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetFromFac<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,18 +41,67 @@
|
|||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
|
||||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll</HintPath>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EntityFramework.SqlServer">
|
<Reference Include="Autofac.Configuration, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.SqlServer.dll</HintPath>
|
<HintPath>..\packages\Autofac.Configuration.3.3.0\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autofac.Integration.Mvc, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Autofac.Mvc5.3.3.4\lib\net45\Autofac.Integration.Mvc.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OptimaJet.Workflow.Core, Version=1.5.5.0, Culture=neutral, PublicKeyToken=3d29392dccd464d7, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\WorkflowEngine.NET-Core.1.5.5.2\lib\net45\OptimaJet.Workflow.Core.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||||
@ -69,10 +118,14 @@
|
|||||||
</Otherwise>
|
</Otherwise>
|
||||||
</Choose>
|
</Choose>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="AutofacExt.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TestBase.cs" />
|
||||||
<Compile Include="TestFunction.cs" />
|
<Compile Include="TestFunction.cs" />
|
||||||
<Compile Include="TestLogin.cs" />
|
<Compile Include="TestLogin.cs" />
|
||||||
<Compile Include="TestAuthen.cs" />
|
<Compile Include="TestAuthen.cs" />
|
||||||
|
<Compile Include="TestCommonApply.cs" />
|
||||||
|
<Compile Include="TestUser.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config">
|
<None Include="App.config">
|
||||||
@ -93,6 +146,10 @@
|
|||||||
<Project>{6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}</Project>
|
<Project>{6108DA8E-92A1-4ABE-B9F5-26D64D55CA2C}</Project>
|
||||||
<Name>OpenAuth.Domain</Name>
|
<Name>OpenAuth.Domain</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\OpenAuth.Mvc\OpenAuth.Mvc.csproj">
|
||||||
|
<Project>{2A9D9687-1822-41CF-B7DF-819BFC0F8FE9}</Project>
|
||||||
|
<Name>OpenAuth.Mvc</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\OpenAuth.Repository\OpenAuth.Repository.csproj">
|
<ProjectReference Include="..\OpenAuth.Repository\OpenAuth.Repository.csproj">
|
||||||
<Project>{E8DF8DEA-E2CF-4BDB-8F4F-3F8205B0E03A}</Project>
|
<Project>{E8DF8DEA-E2CF-4BDB-8F4F-3F8205B0E03A}</Project>
|
||||||
<Name>OpenAuth.Repository</Name>
|
<Name>OpenAuth.Repository</Name>
|
||||||
|
10
OpenAuth.UnitTest/TestBase.cs
Normal file
10
OpenAuth.UnitTest/TestBase.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace OpenAuth.UnitTest
|
||||||
|
{
|
||||||
|
public class TestBase
|
||||||
|
{
|
||||||
|
public TestBase()
|
||||||
|
{
|
||||||
|
AutofacExt.InitDI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
OpenAuth.UnitTest/TestCommonApply.cs
Normal file
59
OpenAuth.UnitTest/TestCommonApply.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.App.ViewModel;
|
||||||
|
using OpenAuth.Domain;
|
||||||
|
using OpenAuth.Mvc.Models;
|
||||||
|
using OptimaJet.Workflow.Core.Persistence;
|
||||||
|
using OptimaJet.Workflow.Core.Runtime;
|
||||||
|
|
||||||
|
namespace OpenAuth.UnitTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 测试通用申请流程
|
||||||
|
/// </summary>
|
||||||
|
[TestClass]
|
||||||
|
public class TestCommonApply : TestBase
|
||||||
|
{
|
||||||
|
private CommonApplyApp _app;
|
||||||
|
|
||||||
|
public TestCommonApply()
|
||||||
|
{
|
||||||
|
_app = AutofacExt.GetFromFac<CommonApplyApp>();
|
||||||
|
Mvc.AutofacExt.InitAutofac();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Addd()
|
||||||
|
{
|
||||||
|
var commonApply = new CommonApply
|
||||||
|
{
|
||||||
|
Id = Guid.Empty,
|
||||||
|
WorkflowName = "新建模板",
|
||||||
|
State = "",
|
||||||
|
StateName = "",
|
||||||
|
Name = "测试"+DateTime.Now.ToLongTimeString()
|
||||||
|
};
|
||||||
|
_app.AddOrUpdate(commonApply);
|
||||||
|
|
||||||
|
CreateWorkflowIfNotExists(commonApply.Id, commonApply.WorkflowName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CreateWorkflowIfNotExists(Guid id, string schemecode)
|
||||||
|
{
|
||||||
|
if (WorkflowInit.Runtime.IsProcessExists(id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
using (var sync = new WorkflowSync(WorkflowInit.Runtime, id))
|
||||||
|
{
|
||||||
|
WorkflowInit.Runtime.CreateInstance(schemecode, id);
|
||||||
|
|
||||||
|
sync.StatrtWaitingFor(new List<ProcessStatus> { ProcessStatus.Initialized, ProcessStatus.Initialized });
|
||||||
|
|
||||||
|
sync.Wait(new TimeSpan(0, 0, 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
53
OpenAuth.UnitTest/TestUser.cs
Normal file
53
OpenAuth.UnitTest/TestUser.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.App.ViewModel;
|
||||||
|
|
||||||
|
namespace OpenAuth.UnitTest
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class TestUser : TestBase
|
||||||
|
{
|
||||||
|
private UserManagerApp _app;
|
||||||
|
|
||||||
|
public TestUser()
|
||||||
|
{
|
||||||
|
_app = AutofacExt.GetFromFac<UserManagerApp>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void AddUser()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var random = new Random();
|
||||||
|
int val = random.Next();
|
||||||
|
_app.AddOrUpdate(new UserView
|
||||||
|
{
|
||||||
|
|
||||||
|
Account = "test" + val,
|
||||||
|
Name = "test" + val,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
OrganizationIds = "990cb229-cc18-41f3-8e2b-13f0f0110798,08f41bf6-4388-4b1e-bd3e-2ff538b44b1b",
|
||||||
|
Organizations = "研发部,研发1组",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GetUser()
|
||||||
|
{
|
||||||
|
var users = _app.Load(new Guid("990cb229-cc18-41f3-8e2b-13f0f0110798"), 2, 30);
|
||||||
|
|
||||||
|
Console.WriteLine(users.total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="EntityFramework" version="6.1.3" targetFramework="net40" requireReinstallation="True" />
|
<package id="Autofac" version="3.5.2" targetFramework="net45" />
|
||||||
|
<package id="Autofac.Configuration" version="3.3.0" targetFramework="net45" />
|
||||||
|
<package id="Autofac.Mvc5" version="3.3.4" targetFramework="net45" />
|
||||||
|
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
|
||||||
|
<package id="WorkflowEngine.NET-Core" version="1.5.5.2" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user