mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
正式解决EF更新问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
@@ -14,74 +15,32 @@ namespace OpenAuth.UnitTest
|
||||
[TestClass]
|
||||
public class TestOrgApp
|
||||
{
|
||||
public TestOrgApp()
|
||||
{
|
||||
//
|
||||
//TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
|
||||
private TestContext testContextInstance;
|
||||
private OrgManagerApp _app = new OrgManagerApp(new OrgRepository());
|
||||
|
||||
/// <summary>
|
||||
///获取或设置测试上下文,该上下文提供
|
||||
///有关当前测试运行及其功能的信息。
|
||||
///</summary>
|
||||
public TestContext TestContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return testContextInstance;
|
||||
}
|
||||
set
|
||||
{
|
||||
testContextInstance = value;
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestAddOrg()
|
||||
{
|
||||
int rootId = _app.AddOrg(new Org
|
||||
int rootId = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "集团总部",
|
||||
ParentId = 0
|
||||
});
|
||||
Assert.IsTrue(rootId != 0);
|
||||
int id = _app.AddOrg(new Org
|
||||
int id = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "一分公司",
|
||||
ParentId = rootId
|
||||
});
|
||||
id = _app.AddOrg(new Org
|
||||
id = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "二分公司",
|
||||
ParentId = rootId
|
||||
});
|
||||
id = _app.AddOrg(new Org
|
||||
id = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "三分公司",
|
||||
ParentId = rootId
|
||||
@@ -93,19 +52,19 @@ namespace OpenAuth.UnitTest
|
||||
[TestMethod]
|
||||
public void TestDelOrg()
|
||||
{
|
||||
int rootId = _app.AddOrg(new Org
|
||||
int rootId = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "即将被删除",
|
||||
ParentId = 0
|
||||
});
|
||||
Assert.IsTrue(rootId != 0);
|
||||
|
||||
int id = _app.AddOrg(new Org
|
||||
int id = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "即将被删除1",
|
||||
ParentId = rootId
|
||||
});
|
||||
id = _app.AddOrg(new Org
|
||||
id = _app.AddOrUpdate(new Org
|
||||
{
|
||||
Name = "即将被删除2",
|
||||
ParentId = id
|
||||
@@ -129,13 +88,16 @@ namespace OpenAuth.UnitTest
|
||||
[TestMethod]
|
||||
public void TestEdit()
|
||||
{
|
||||
var org = new Org
|
||||
{
|
||||
Id = 60,
|
||||
Name = "test"
|
||||
//var org = _app.GetAll().FirstOrDefault();
|
||||
//org.Name = DateTime.Now.ToShortTimeString();
|
||||
//_app.AddOrUpdate(org);
|
||||
|
||||
var org1 = new Org
|
||||
{
|
||||
Id = 1,
|
||||
Name = DateTime.Now.ToShortTimeString()
|
||||
};
|
||||
_app.ModifyOrg(org);
|
||||
_app.AddOrUpdate(org1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user