1 增加UnitWork

2 修改UnitTest项目为C# 6.0
This commit is contained in:
yubaolee
2016-04-29 16:26:09 +08:00
parent 606452b2e7
commit 40666863d9
8 changed files with 258 additions and 14 deletions

View File

@@ -29,6 +29,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -61,7 +62,9 @@
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
<Private>False</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
@@ -72,6 +75,7 @@
<Compile Include="TestModuleApp.cs" />
<Compile Include="TestRepository.cs" />
<Compile Include="TestRoleApp.cs" />
<Compile Include="TestUnitWork.cs" />
<Compile Include="TestUserApp.cs" />
<Compile Include="TestOrgApp.cs" />
</ItemGroup>

View File

@@ -0,0 +1,38 @@
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($"{user.Name} :{user.OrgName}");
}
}
}
}