全面修改Id为Guid类型,为2.0版做准备

This commit is contained in:
yubaolee
2016-09-02 18:05:17 +08:00
parent a8fd59e247
commit 574f5f9e1f
327 changed files with 10071 additions and 18206 deletions

View File

@@ -72,12 +72,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFunction.cs" />
<Compile Include="TestLogin.cs" />
<Compile Include="TestModuleApp.cs" />
<Compile Include="TestRepository.cs" />
<Compile Include="TestRoleApp.cs" />
<Compile Include="TestUnitWork.cs" />
<Compile Include="TestUserApp.cs" />
<Compile Include="TestOrgApp.cs" />
<Compile Include="TestAuthen.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,118 +0,0 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.Domain;
using OpenAuth.Domain.Service;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestModuleApp 的摘要说明
/// </summary>
[TestClass]
public class TestModuleApp
{
private TestContext testContextInstance;
private ModuleManagerApp _app ;
private string _time = DateTime.Now.ToString("HH_mm_ss_ms");
//初始化导航
[TestMethod]
public void InitNav()
{
var root = new Module()
{
Name = "基础设置",
ParentId = 0
};
_app.AddOrUpdate(root);
var module = new Module
{
Name = "模块管理",
Url = "ModuleManager/Index",
ParentId = root.Id
};
_app.AddOrUpdate(module);
module = new Module
{
Name = "用户管理",
Url = "UserManager/Index",
ParentId = root.Id
};
_app.AddOrUpdate(module);
module = new Module
{
Name = "角色管理",
Url = "RoleManager/Index",
ParentId = root.Id
};
_app.AddOrUpdate(module);
module = new Module
{
Name = "机构管理",
Url = "OrgManager/Index",
ParentId = root.Id
};
_app.AddOrUpdate(module);
}
[TestMethod]
public void TestAddModule()
{
var root = Add();
for (int i = 0; i < 30; i++)
{
Add(root.Id);
}
}
[TestMethod]
public void TestDelModule()
{
var root = Add(0);
_app.Delete(root.Id);
}
[TestMethod]
public void TestEdit()
{
//var module = _app.Find(7);
//_app.AddOrUpdate(module);
var module1 = new Module
{
Id = 14,
Name = DateTime.Now.ToString()
};
_app.AddOrUpdate(module1);
}
[TestMethod]
public void TestLoad()
{
}
public Module Add(int parent = 0)
{
var module = new Module()
{
Name = "test_" + _time,
ParentId = parent,
IconName = null,
HotKey = null
};
_app.AddOrUpdate(module);
return module;
}
}
}

View File

@@ -1,109 +0,0 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestOrgApp 的摘要说明
/// </summary>
[TestClass]
public class TestOrgApp
{
private TestContext testContextInstance;
private OrgManagerApp _app = new OrgManagerApp(new OrgRepository(), new RelevanceRepository());
[TestMethod]
public void TestAddOrg()
{
int rootId = _app.AddOrUpdate(new Org
{
Name = "集团总部",
ParentId = 0
});
Assert.IsTrue(rootId != 0);
int id = _app.AddOrUpdate(new Org
{
Name = "一分公司",
ParentId = rootId
});
id = _app.AddOrUpdate(new Org
{
Name = "二分公司",
ParentId = rootId
});
id = _app.AddOrUpdate(new Org
{
Name = "三分公司",
ParentId = rootId
});
Assert.IsTrue(id != 0);
}
[TestMethod]
public void TestDelOrg()
{
int rootId = _app.AddOrUpdate(new Org
{
Name = "即将被删除",
ParentId = 0
});
Assert.IsTrue(rootId != 0);
int id = _app.AddOrUpdate(new Org
{
Name = "即将被删除1",
ParentId = rootId
});
id = _app.AddOrUpdate(new Org
{
Name = "即将被删除2",
ParentId = id
});
_app.DelOrg(rootId);
}
[TestMethod]
public void TestLoadOrg()
{
var orgs = _app.GetAll();
foreach (var org in orgs)
{
Console.WriteLine(org.Name);
}
}
[TestMethod]
public void TestEdit()
{
//var org = _app.GetAll().FirstOrDefault();
//org.Name = DateTime.Now.ToShortTimeString();
//_app.AddOrUpdate(org);
var org1 = new Org
{
Id = 1,
Name = DateTime.Now.ToShortTimeString()
};
_app.AddOrUpdate(org1);
}
[TestMethod]
public void TestLoadByUser()
{
var user = _app.LoadForUser(5);
}
}
}

View File

@@ -1,65 +0,0 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestRepository 的摘要说明
/// </summary>
[TestClass]
public class TestRepository
{
#region
//
// 编写测试时,可以使用以下附加特性:
//
// 在运行类中的第一个测试之前使用 ClassInitialize 运行代码
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// 在类中的所有测试都已运行之后使用 ClassCleanup 运行代码
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// 在运行每个测试之前,使用 TestInitialize 来运行代码
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// 在每个测试运行完之后,使用 TestCleanup 来运行代码
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
//测试被EF跟踪的对象修改
[TestMethod]
public void TestTrackingEdit()
{
var moduleRep = new ModuleRepository();
//var module = moduleRep.FindSingle(u => u.Id == 14);
//module.CascadeId = DateTime.Now.ToShortTimeString();
//如果不加u.Id !=7 则会造成异常,可理解为数据库的默认隔离级别为“读已提交”,不允许脏读!
//var obstruct = moduleRep.Find(u =>u.Id != 7);
//foreach (var module1 in obstruct)
//{
// module.CascadeId += module1.CascadeId;
//}
//moduleRep.Update(module);
moduleRep.Update(u =>u.Id, new Module
{
Id = 15,
Name = "test",
CascadeId = DateTime.Now.ToShortTimeString(),
Url = "ssss"
});
}
}
}

View File

@@ -1,81 +0,0 @@
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(),
new RelevanceRepository());
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,39 +0,0 @@
using System;
using System.Diagnostics;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestUnitWork 的摘要说明
/// </summary>
[TestClass]
public class TestUnitWork
{
IUnitWork _unit = new UnitWork();
/// <summary>
/// 测试UnitWork用于联表查询
/// </summary>
[TestMethod]
public void GetDynamic()
{
var usersInOrg = from user in _unit.Find<User>(null)
join relevance in _unit.Find<Relevance>(u => u.Key == "UserOrg") on user.Id equals relevance.FirstId
join org in _unit.Find<Org>(null) on relevance.SecondId equals org.Id
select new
{
user.Name,
OrgName = org.Name
};
foreach (var user in usersInOrg)
{
Debug.WriteLine("{0} :{1}", user.Name, user.OrgName);
}
}
}
}

View File

@@ -1,108 +0,0 @@
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(), new RelevanceRepository());
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);
}
[TestMethod]
public void TestFind()
{
var user = _app.Find(21);
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;
}
[TestMethod]
public void TestEditExist()
{
var user = new UserView
{
Id = 1,
Account = "admin",
Name = "管理员",
OrganizationIds = "1,2",
Organizations = "集团总部,研发部",
Status = 1
};
_app.AddOrUpdate(user);
Console.WriteLine(user.Name + " \t用户ID" + user.Id);
}
}
}