OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2009 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 using System; | |
7 using System.IO; | |
8 using EnvDTE; | |
9 using Microsoft.VisualStudio.TestTools.UnitTesting; | |
10 using Microsoft.VsSDK.IntegrationTestLibrary; | |
11 using Microsoft.VSSDK.Tools.VsIdeTesting; | |
12 | |
13 namespace IntegrationTests { | |
14 [TestClass] | |
15 public class CPPProjectTests { | |
16 #region fields | |
17 | |
18 private delegate void ThreadInvoker(); | |
19 | |
20 #endregion | |
21 | |
22 #region properties | |
23 | |
24 /// <summary> | |
25 ///Gets or sets the test context which provides | |
26 ///information about and functionality for the current test run. | |
27 ///</summary> | |
28 public TestContext TestContext { get; set; } | |
29 | |
30 #endregion | |
31 | |
32 #region ctors | |
33 | |
34 #endregion | |
35 | |
36 #region Additional test attributes | |
37 | |
38 // | |
39 // You can use the following additional attributes as you write your tests: | |
40 // | |
41 // Use ClassInitialize to run code before running the first test in the clas
s | |
42 // [ClassInitialize()] | |
43 // public static void MyClassInitialize(TestContext testContext) { } | |
44 // | |
45 // Use ClassCleanup to run code after all tests in a class have run | |
46 // [ClassCleanup()] | |
47 // public static void MyClassCleanup() { } | |
48 // | |
49 // Use TestInitialize to run code before running each test | |
50 // [TestInitialize()] | |
51 // public void MyTestInitialize() { } | |
52 // | |
53 // Use TestCleanup to run code after each test has run | |
54 // [TestCleanup()] | |
55 // public void MyTestCleanup() { } | |
56 // | |
57 | |
58 #endregion | |
59 | |
60 [TestMethod] | |
61 public void CPPWinformsApplication() { | |
62 UIThreadInvoker.Invoke((ThreadInvoker) delegate { | |
63 //Solution and project creation p
arameters | |
64 string solutionName = | |
65 "CreateCPPWinformsApplication
"; | |
66 string projectName = | |
67 "CPPWindowsApp"; | |
68 | |
69 //Template parameters | |
70 string projectType = | |
71 "{8BC9CEB8-8B4A-11D0-8D11-00A
0C91BC942}"; | |
72 string projectTemplateName = | |
73 "mc++winapp.vsz"; | |
74 | |
75 string itemTemplateName = | |
76 "newc++file.cpp"; | |
77 string newFileName = "Test.cpp"; | |
78 | |
79 var dte = | |
80 (DTE) | |
81 VsIdeTestHostContext. | |
82 ServiceProvider. | |
83 GetService(typeof (DTE)); | |
84 | |
85 var testUtils = new TestUtils(); | |
86 | |
87 testUtils.CreateEmptySolution( | |
88 TestContext.TestDir, | |
89 solutionName); | |
90 Assert.AreEqual(0, | |
91 testUtils. | |
92 ProjectCount(
)); | |
93 | |
94 //Add new CPP Windows application
project to existing solution | |
95 string solutionDirectory = | |
96 Directory.GetParent( | |
97 dte.Solution.FullName). | |
98 FullName; | |
99 string projectDirectory = | |
100 TestUtils.GetNewDirectoryName | |
101 (solutionDirectory, | |
102 projectName); | |
103 string projectTemplatePath = | |
104 Path.Combine( | |
105 dte.Solution. | |
106 get_TemplatePath( | |
107 projectType), | |
108 projectTemplateName); | |
109 Assert.IsTrue( | |
110 File.Exists( | |
111 projectTemplatePath), | |
112 string.Format( | |
113 "Could not find template
file: {0}", | |
114 projectTemplatePath)); | |
115 dte.Solution.AddFromTemplate( | |
116 projectTemplatePath, | |
117 projectDirectory, | |
118 projectName, | |
119 false); | |
120 | |
121 //Verify that the new project has
been added to the solution | |
122 Assert.AreEqual(1, | |
123 testUtils. | |
124 ProjectCount(
)); | |
125 | |
126 //Get the project | |
127 Project project = | |
128 dte.Solution.Item(1); | |
129 Assert.IsNotNull(project); | |
130 Assert.IsTrue( | |
131 string.Compare(project.Name, | |
132 projectName, | |
133 StringComparis
on | |
134 . | |
135 InvariantC
ultureIgnoreCase) == | |
136 0); | |
137 | |
138 //Verify Adding new code file to
project | |
139 string newItemTemplatePath = | |
140 Path.Combine( | |
141 dte.Solution. | |
142 ProjectItemsTemplateP
ath | |
143 (projectType), | |
144 itemTemplateName); | |
145 Assert.IsTrue( | |
146 File.Exists( | |
147 newItemTemplatePath)); | |
148 ProjectItem item = | |
149 project.ProjectItems. | |
150 AddFromTemplate( | |
151 newItemTemplatePath, | |
152 newFileName); | |
153 Assert.IsNotNull(item); | |
154 }); | |
155 } | |
156 } | |
157 } | |
OLD | NEW |