Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d51f5f70
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d51f5f70
编写于
8月 16, 2018
作者:
J
Jason Malinowski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more tests for incremental updates to the project dependency graph
上级
da1b4c2c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
119 addition
and
13 deletion
+119
-13
src/Workspaces/CoreTest/SolutionTests/ProjectDependencyGraphTests.cs
...ces/CoreTest/SolutionTests/ProjectDependencyGraphTests.cs
+119
-13
未找到文件。
src/Workspaces/CoreTest/SolutionTests/ProjectDependencyGraphTests.cs
浏览文件 @
d51f5f70
...
...
@@ -20,15 +20,34 @@ public class ProjectDependencyGraphTests : TestBase
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestGetTopologicallySortedProjects
()
{
VerifyTopologicalSort
(
"A"
,
"A"
);
VerifyTopologicalSort
(
"A B"
,
"AB"
,
"BA"
);
VerifyTopologicalSort
(
"C:A,B B:A A"
,
"ABC"
);
VerifyTopologicalSort
(
"B:A A C:A D:C,B"
,
"ABCD"
,
"ACBD"
);
VerifyTopologicalSort
(
CreateSolutionFromReferenceMap
(
"A"
)
,
"A"
);
VerifyTopologicalSort
(
CreateSolutionFromReferenceMap
(
"A B"
)
,
"AB"
,
"BA"
);
VerifyTopologicalSort
(
CreateSolutionFromReferenceMap
(
"C:A,B B:A A"
)
,
"ABC"
);
VerifyTopologicalSort
(
CreateSolutionFromReferenceMap
(
"B:A A C:A D:C,B"
)
,
"ABCD"
,
"ACBD"
);
}
private
void
VerifyTopologicalSort
(
string
projectReferences
,
params
string
[]
expectedResults
)
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestTopologicallySortedProjectsIncrementalUpdate
()
{
var
solution
=
CreateSolutionFromReferenceMap
(
"A"
);
VerifyTopologicalSort
(
solution
,
"A"
);
solution
=
AddProject
(
solution
,
"B"
);
VerifyTopologicalSort
(
solution
,
"AB"
,
"BA"
);
}
/// <summary>
/// Verifies that <see cref="ProjectDependencyGraph.GetTopologicallySortedProjects(CancellationToken)"/>
/// returns one of the correct results.
/// </summary>
/// <param name="solution"></param>
/// <param name="expectedResults">A list of possible results. Because topological sorting is ambiguous
/// in that a graph could have multiple topological sorts, this helper lets you give all the possible
/// results and it asserts that one of them does match.</param>
private
void
VerifyTopologicalSort
(
Solution
solution
,
params
string
[]
expectedResults
)
{
Solution
solution
=
CreateSolutionFromReferenceMap
(
projectReferences
);
var
projectDependencyGraph
=
solution
.
GetProjectDependencyGraph
();
var
projectIds
=
projectDependencyGraph
.
GetTopologicallySortedProjects
(
CancellationToken
.
None
);
...
...
@@ -44,16 +63,27 @@ private void VerifyTopologicalSort(string projectReferences, params string[] exp
[
WorkItem
(
542438
,
"http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542438"
)]
public
void
TestGetDependencySets
()
{
VerifyDependencySets
(
"A B:A C:A D E:D F:D"
,
"ABC DEF"
);
VerifyDependencySets
(
"A B:A,C C"
,
"ABC"
);
VerifyDependencySets
(
"A B"
,
"A B"
);
VerifyDependencySets
(
"A B C:B"
,
"A BC"
);
VerifyDependencySets
(
"A B:A C:A D:B,C"
,
"ABCD"
);
VerifyDependencySets
(
CreateSolutionFromReferenceMap
(
"A B:A C:A D E:D F:D"
)
,
"ABC DEF"
);
VerifyDependencySets
(
CreateSolutionFromReferenceMap
(
"A B:A,C C"
)
,
"ABC"
);
VerifyDependencySets
(
CreateSolutionFromReferenceMap
(
"A B"
)
,
"A B"
);
VerifyDependencySets
(
CreateSolutionFromReferenceMap
(
"A B C:B"
)
,
"A BC"
);
VerifyDependencySets
(
CreateSolutionFromReferenceMap
(
"A B:A C:A D:B,C"
)
,
"ABCD"
);
}
private
void
VerifyDependencySets
(
string
projectReferences
,
string
expectedResult
)
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestDependencySetsIncrementalUpdate
()
{
var
solution
=
CreateSolutionFromReferenceMap
(
"A"
);
VerifyDependencySets
(
solution
,
"A"
);
solution
=
AddProject
(
solution
,
"B"
);
VerifyDependencySets
(
solution
,
"A B"
);
}
private
void
VerifyDependencySets
(
Solution
solution
,
string
expectedResult
)
{
Solution
solution
=
CreateSolutionFromReferenceMap
(
projectReferences
);
var
projectDependencyGraph
=
solution
.
GetProjectDependencyGraph
();
var
projectIds
=
projectDependencyGraph
.
GetDependencySets
(
CancellationToken
.
None
);
var
actualResult
=
string
.
Join
(
" "
,
...
...
@@ -76,6 +106,15 @@ public void TestGetProjectsThatThisProjectTransitivelyDependsOn()
VerifyTransitiveReferences
(
CreateSolutionFromReferenceMap
(
"C:B B:A A"
),
"A"
,
new
string
[]
{
});
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestGetProjectsThatThisProjectTransitivelyDependsOnThrowsArgumentNull
()
{
var
solution
=
CreateSolutionFromReferenceMap
(
""
);
Assert
.
Throws
<
ArgumentNullException
>(
"projectId"
,
()
=>
solution
.
GetProjectDependencyGraph
().
GetProjectsThatThisProjectDirectlyDependsOn
(
null
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestTransitiveReferencesIncrementalUpdateInMiddle
()
{
...
...
@@ -112,6 +151,33 @@ public void TestTransitiveReferencesIncrementalUpdateInMiddle()
VerifyTransitiveReferences
(
solution
,
"D"
,
new
string
[]
{
});
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestTransitiveReferencesIncrementalUpdateWithReferencesAlreadyTransitivelyIncluded
()
{
// We are going to create a solution with the references:
//
// A -> B -> C
//
// and then we'll add a reference from A -> C, and transitive references should be different
var
solution
=
CreateSolutionFromReferenceMap
(
"A:B B:C C"
);
void
VerifyAllTransitiveReferences
()
{
VerifyTransitiveReferences
(
solution
,
"A"
,
new
string
[]
{
"B"
,
"C"
});
VerifyTransitiveReferences
(
solution
,
"B"
,
new
string
[]
{
"C"
});
VerifyTransitiveReferences
(
solution
,
"C"
,
new
string
[]
{
});
}
VerifyAllTransitiveReferences
();
VerifyDirectReferences
(
solution
,
"A"
,
new
string
[]
{
"B"
});
solution
=
AddProjectReferences
(
solution
,
"A"
,
new
string
[]
{
"C"
});
VerifyAllTransitiveReferences
();
VerifyDirectReferences
(
solution
,
"A"
,
new
string
[]
{
"B"
,
"C"
});
}
private
void
VerifyDirectReferences
(
Solution
solution
,
string
project
,
string
[]
expectedResults
)
{
var
projectDependencyGraph
=
solution
.
GetProjectDependencyGraph
();
...
...
@@ -138,6 +204,20 @@ private void VerifyTransitiveReferences(Solution solution, string project, strin
#
endregion
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestDirectAndReverseDirectReferencesAfterWithProjectReferences
()
{
var
solution
=
CreateSolutionFromReferenceMap
(
"A:B B"
);
VerifyDirectReverseReferences
(
solution
,
"B"
,
new
string
[]
{
"A"
});
solution
=
solution
.
WithProjectReferences
(
solution
.
GetProjectsByName
(
"A"
).
Single
().
Id
,
Enumerable
.
Empty
<
ProjectReference
>());
VerifyDirectReferences
(
solution
,
"A"
,
new
string
[]
{
});
VerifyDirectReverseReferences
(
solution
,
"B"
,
new
string
[]
{
});
}
#
region
GetProjectsThatTransitivelyDependOnThisProject
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
...
...
@@ -150,6 +230,15 @@ public void TestGetProjectsThatTransitivelyDependOnThisProject()
VerifyReverseTransitiveReferences
(
CreateSolutionFromReferenceMap
(
"D:C,B B:A C A"
),
"A"
,
new
string
[]
{
"D"
,
"B"
});
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestGetProjectsThatTransitivelyDependOnThisProjectThrowsArgumentNull
()
{
var
solution
=
CreateSolutionFromReferenceMap
(
""
);
Assert
.
Throws
<
ArgumentNullException
>(
"projectId"
,
()
=>
solution
.
GetProjectDependencyGraph
().
GetProjectsThatTransitivelyDependOnThisProject
(
null
));
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
Workspace
)]
public
void
TestReverseTransitiveReferencesIncrementalUpdateInMiddle
()
{
...
...
@@ -168,6 +257,9 @@ public void TestReverseTransitiveReferencesIncrementalUpdateInMiddle()
solution
=
AddProjectReferences
(
solution
,
"A"
,
new
string
[]
{
"B"
});
solution
=
AddProjectReferences
(
solution
,
"C"
,
new
string
[]
{
"D"
});
VerifyDirectReverseReferences
(
solution
,
"B"
,
new
string
[]
{
"A"
});
VerifyDirectReverseReferences
(
solution
,
"D"
,
new
string
[]
{
"C"
});
VerifyReverseTransitiveReferences
(
solution
,
"A"
,
new
string
[]
{
});
VerifyReverseTransitiveReferences
(
solution
,
"B"
,
new
string
[]
{
"A"
});
VerifyReverseTransitiveReferences
(
solution
,
"C"
,
new
string
[]
{
});
...
...
@@ -175,12 +267,26 @@ public void TestReverseTransitiveReferencesIncrementalUpdateInMiddle()
solution
=
AddProjectReferences
(
solution
,
"B"
,
new
string
[]
{
"C"
});
VerifyDirectReverseReferences
(
solution
,
"C"
,
new
string
[]
{
"B"
});
VerifyReverseTransitiveReferences
(
solution
,
"A"
,
new
string
[]
{
});
VerifyReverseTransitiveReferences
(
solution
,
"B"
,
new
string
[]
{
"A"
});
VerifyReverseTransitiveReferences
(
solution
,
"C"
,
new
string
[]
{
"A"
,
"B"
});
VerifyReverseTransitiveReferences
(
solution
,
"D"
,
new
string
[]
{
"A"
,
"B"
,
"C"
});
}
private
void
VerifyDirectReverseReferences
(
Solution
solution
,
string
project
,
string
[]
expectedResults
)
{
var
projectDependencyGraph
=
solution
.
GetProjectDependencyGraph
();
var
projectId
=
solution
.
GetProjectsByName
(
project
).
Single
().
Id
;
var
projectIds
=
projectDependencyGraph
.
GetProjectsThatDirectlyDependOnThisProject
(
projectId
);
var
actualResults
=
projectIds
.
Select
(
id
=>
solution
.
GetProject
(
id
).
Name
);
Assert
.
Equal
<
string
>(
expectedResults
.
OrderBy
(
n
=>
n
),
actualResults
.
OrderBy
(
n
=>
n
));
}
private
void
VerifyReverseTransitiveReferences
(
Solution
solution
,
string
project
,
string
[]
expectedResults
)
{
var
projectDependencyGraph
=
solution
.
GetProjectDependencyGraph
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录