/
AssemblyIdentityTest.cs
125 lines (111 loc) · 4.71 KB
/
AssemblyIdentityTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using Microsoft.Build.Tasks.Deployment.ManifestUtilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
namespace XMakeTasksUnitTests
{
/// <summary>
///This is a test class for AssemblyIdentityTest and is intended
///to contain all AssemblyIdentityTest Unit Tests
///</summary>
[TestClass()]
public class AssemblyIdentityTest
{
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
/// <summary>
///A test for IsFrameworkAssembly
///</summary>
[TestMethod()]
public void IsFrameworkAssemblyTest()
{
bool actual;
IList<string> listOfInstalledFrameworks = FrameworkMultiTargeting.GetSupportedTargetFrameworks();
// if 2.0 is installed on this computer, we will test IsFrameworkAssembly for 2.0 assemblies.
if (hasVersion(listOfInstalledFrameworks, "Version=v2.0"))
{
//if (hasVersion(listOfInstalledFrameworks
// Test 2.0 CLR binary
// "Microsoft.Build.Engine" Version="2.0.0.0" PublicKeyToken="b03f5f7f11d50a3a" Culture="neutral" ProcessorArchitecture="MSIL" FileVersion="2.0.50727.3026" InGAC="true" />
AssemblyIdentity clr2Binary = new AssemblyIdentity("Microsoft.Build.Engine", "2.0.0.0", "b03f5f7f11d50a3a", "neutral", "MSIL");
actual = clr2Binary.IsFrameworkAssembly;
Assert.IsTrue(actual);
}
if (hasVersion(listOfInstalledFrameworks, "Version=v3.0"))
{
// Test 3.0 CLR binary
// AssemblyName="System.ServiceModel" Version="3.0.0.0" PublicKeyToken="b77a5c561934e089" Culture="neutral" ProcessorArchitecture="MSIL" InGAC="false" IsRedistRoot="true" />
AssemblyIdentity clr3Binary = new AssemblyIdentity("System.ServiceModel", "3.0.0.0", "b77a5c561934e089", "neutral", "MSIL");
actual = clr3Binary.IsFrameworkAssembly;
Assert.IsTrue(actual);
}
if (hasVersion(listOfInstalledFrameworks, "Version=v3.5"))
{
// Test 3.5 CLR binary
// AssemblyName="Microsoft.Build.Tasks.v3.5" Version="3.5.0.0" PublicKeyToken="b03f5f7f11d50a3a" Culture="neutral" ProcessorArchitecture="MSIL" InGAC="false" />
AssemblyIdentity clr35Binary = new AssemblyIdentity("Microsoft.Build.Tasks.v3.5", "3.5.0.0", "b03f5f7f11d50a3a", "neutral", "MSIL");
actual = clr35Binary.IsFrameworkAssembly;
Assert.IsTrue(actual);
}
if (hasVersion(listOfInstalledFrameworks, "Version=v4.0"))
{
// Test 4.0 CLR binary
// AssemblyName="Microsoft.VisualBasic" Version="10.0.0.0" PublicKeyToken="b03f5f7f11d50a3a" Culture="neutral" ProcessorArchitecture="MSIL" FileVersion="4.0.41117.0" InGAC="true" />
AssemblyIdentity clr4Binary = new AssemblyIdentity("Microsoft.VisualBasic", "10.0.0.0", "b03f5f7f11d50a3a", "neutral", "MSIL");
actual = clr4Binary.IsFrameworkAssembly;
Assert.IsTrue(actual);
}
}
private bool hasVersion(IList<string> listOfInstalledFrameworks, string p)
{
foreach (string fx in listOfInstalledFrameworks)
{
if (fx.Contains(p))
return true;
}
return false;
}
}
}