添加角色处理

This commit is contained in:
yubaolee
2015-11-19 21:49:39 +08:00
parent 6906e969ac
commit 119948ccb7
24 changed files with 1763 additions and 899 deletions

View File

@@ -66,6 +66,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFunction.cs" />
<Compile Include="TestRoleApp.cs" />
<Compile Include="TestUserApp.cs" />
<Compile Include="TestOrgApp.cs" />
</ItemGroup>

View File

@@ -0,0 +1,79 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestOrgApp 的摘要说明
/// </summary>
[TestClass]
public class TestRoleApp
{
private RoleManagerApp _app = new RoleManagerApp(new RoleRepository(), new OrgRepository());
private string _time = DateTime.Now.ToString("HH_mm_ss_ms");
[TestMethod]
public void TestAdd()
{
for (int i = 0; i < 30; i++)
{
Add();
}
}
[TestMethod]
public void TestDel()
{
var role = new Role
{
Name = "即将删除" + _time,
CreateTime = DateTime.Now,
OrgId = 1
};
_app.AddOrUpdate(role);
Console.WriteLine("new role:" + role.Id);
_app.Delete(role.Id);
}
[TestMethod]
public void TestLoad()
{
var users = _app.Load(1,1, 10);
}
[TestMethod]
public void TestEdit()
{
var role = Add();
role.Name = "修改后的名称" + _time;
_app.AddOrUpdate(role);
Console.WriteLine(role.Name);
}
private Role Add()
{
var role = new Role
{
Name = "test_" + _time,
CreateTime = DateTime.Now,
OrgId = 1
};
_app.AddOrUpdate(role);
return role;
}
}
}

View File

@@ -1,83 +1,83 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestOrgApp 的摘要说明
/// </summary>
[TestClass]
public class TestUserApp
{
private UserManagerApp _app = new UserManagerApp(new UserRepository(), new OrgRepository());
private string _time = DateTime.Now.ToString("HH_mm_ss_ms");
[TestMethod]
public void TestAdd()
{
for (int i = 0; i < 30; i++)
{
Add();
}
}
[TestMethod]
public void TestDel()
{
var user = new UserView
{
Account = "user" + _time,
Name = "即将被删除的账号" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine("new user:" + user.Id);
_app.Delete(user.Id);
}
[TestMethod]
public void TestLoad()
{
var users = _app.Load(1,1, 10);
}
[TestMethod]
public void TestEdit()
{
var user = Add();
user.Name = "修改后的名称" + _time;
_app.AddOrUpdate(user);
Console.WriteLine(user.Name);
}
private UserView Add()
{
var user = new UserView
{
Account = "user" + _time,
Name = "新用户" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine(user.Name + " \t用户ID" + user.Id);
return user;
}
}
}
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestOrgApp 的摘要说明
/// </summary>
[TestClass]
public class TestUserApp
{
private UserManagerApp _app = new UserManagerApp(new UserRepository(), new OrgRepository());
private string _time = DateTime.Now.ToString("HH_mm_ss_ms");
[TestMethod]
public void TestAdd()
{
for (int i = 0; i < 30; i++)
{
Add();
}
}
[TestMethod]
public void TestDel()
{
var user = new UserView
{
Account = "user" + _time,
Name = "即将被删除的账号" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine("new user:" + user.Id);
_app.Delete(user.Id);
}
[TestMethod]
public void TestLoad()
{
var users = _app.Load(1,1, 10);
}
[TestMethod]
public void TestEdit()
{
var user = Add();
user.Name = "修改后的名称" + _time;
_app.AddOrUpdate(user);
Console.WriteLine(user.Name);
}
private UserView Add()
{
var user = new UserView
{
Account = "user" + _time,
Name = "新用户" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine(user.Name + " \t用户ID" + user.Id);
return user;
}
}
}