PageRenderTime 32ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/GalleryTemplatesClientTests.cs

https://gitlab.com/jslee1/azure-powershell
C# | 507 lines | 415 code | 79 blank | 13 comment | 0 complexity | f7f0581f6fcdbaed5d8421ac5f3e8fd9 MD5 | raw file
  1. // ----------------------------------------------------------------------------------
  2. //
  3. // Copyright Microsoft Corporation
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // ----------------------------------------------------------------------------------
  14. using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
  15. using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
  16. using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
  17. using Microsoft.Azure.Management.ResourceManager;
  18. using Microsoft.WindowsAzure.Commands.ScenarioTest;
  19. using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
  20. using Moq;
  21. using System;
  22. using System.Collections;
  23. using System.Collections.Generic;
  24. using System.IO;
  25. using System.Linq;
  26. using System.Management.Automation;
  27. using System.Security;
  28. using Newtonsoft.Json.Linq;
  29. using Xunit;
  30. using Xunit.Abstractions;
  31. using Microsoft.Azure.ServiceManagemenet.Common.Models;
  32. namespace Microsoft.Azure.Commands.Resources.Test.Models
  33. {
  34. public class GalleryTemplatesClientTests : RMTestBase
  35. {
  36. private ResourceManagerSdkClient resourceManagerSdkClient;
  37. private Mock<IResourceManagementClient> resourceManagementClientMock;
  38. private string templateFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\sampleTemplateFile.json");
  39. private string invalidTemplateFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\invalidTemplateFile.json");
  40. private string templateParameterFileSchema1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\sampleTemplateParameterFile.json");
  41. private string templateParameterFileSchema2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\sampleTemplateParameterFileSchema2.json");
  42. public GalleryTemplatesClientTests(ITestOutputHelper output)
  43. {
  44. resourceManagementClientMock = new Mock<IResourceManagementClient>();
  45. XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
  46. resourceManagerSdkClient = new ResourceManagerSdkClient(resourceManagementClientMock.Object);
  47. }
  48. [Fact]
  49. [Trait(Category.AcceptanceType, Category.CheckIn)]
  50. public void ConstructsDynamicParameter()
  51. {
  52. string[] parameters = { "Name", "Location", "Mode" };
  53. string[] parameterSetNames = { "__AllParameterSets" };
  54. string key = "computeMode";
  55. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  56. {
  57. AllowedValues = new List<object>() { "Mode1", "Mode2", "Mode3" },
  58. DefaultValue = "Mode1",
  59. MaxLength = "5",
  60. MinLength = "1",
  61. Type = "string"
  62. };
  63. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  64. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  65. Assert.Equal("computeMode", dynamicParameter.Name);
  66. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  67. Assert.Equal(typeof(string), dynamicParameter.ParameterType);
  68. Assert.Equal(2, dynamicParameter.Attributes.Count);
  69. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  70. Assert.False(parameterAttribute.Mandatory);
  71. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  72. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  73. ValidateLengthAttribute validateLengthAttribute = (ValidateLengthAttribute)dynamicParameter.Attributes[1];
  74. Assert.Equal(int.Parse(value.MinLength), validateLengthAttribute.MinLength);
  75. Assert.Equal(int.Parse(value.MaxLength), validateLengthAttribute.MaxLength);
  76. }
  77. [Fact]
  78. [Trait(Category.AcceptanceType, Category.CheckIn)]
  79. public void ResolvesDuplicatedDynamicParameterName()
  80. {
  81. string[] parameters = { "Name", "Location", "Mode" };
  82. string[] parameterSetNames = { "__AllParameterSets" };
  83. string key = "Name";
  84. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  85. {
  86. AllowedValues = new List<object>() { "Mode1", "Mode2", "Mode3" },
  87. MaxLength = "5",
  88. MinLength = "1",
  89. Type = "bool"
  90. };
  91. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  92. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  93. Assert.Equal(key + "FromTemplate", dynamicParameter.Name);
  94. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  95. Assert.Equal(typeof(bool), dynamicParameter.ParameterType);
  96. Assert.Equal(2, dynamicParameter.Attributes.Count);
  97. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  98. Assert.True(parameterAttribute.Mandatory);
  99. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  100. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  101. ValidateLengthAttribute validateLengthAttribute = (ValidateLengthAttribute)dynamicParameter.Attributes[1];
  102. Assert.Equal(int.Parse(value.MinLength), validateLengthAttribute.MinLength);
  103. Assert.Equal(int.Parse(value.MaxLength), validateLengthAttribute.MaxLength);
  104. }
  105. [Fact]
  106. [Trait(Category.AcceptanceType, Category.CheckIn)]
  107. public void ResolvesDuplicatedDynamicParameterNameSubstring()
  108. {
  109. string[] parameters = { "Username", "Location", "Mode" };
  110. string[] parameterSetNames = { "__AllParameterSets" };
  111. string key = "user";
  112. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  113. {
  114. AllowedValues = new List<object>() { "Mode1", "Mode2", "Mode3" },
  115. MaxLength = "5",
  116. MinLength = "1",
  117. Type = "bool"
  118. };
  119. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  120. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  121. Assert.Equal(key + "FromTemplate", dynamicParameter.Name);
  122. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  123. Assert.Equal(typeof(bool), dynamicParameter.ParameterType);
  124. Assert.Equal(2, dynamicParameter.Attributes.Count);
  125. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  126. Assert.True(parameterAttribute.Mandatory);
  127. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  128. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  129. ValidateLengthAttribute validateLengthAttribute = (ValidateLengthAttribute)dynamicParameter.Attributes[1];
  130. Assert.Equal(int.Parse(value.MinLength), validateLengthAttribute.MinLength);
  131. Assert.Equal(int.Parse(value.MaxLength), validateLengthAttribute.MaxLength);
  132. }
  133. [Fact]
  134. [Trait(Category.AcceptanceType, Category.CheckIn)]
  135. public void ResolvesDuplicatedDynamicParameterNameCaseInsensitive()
  136. {
  137. string[] parameters = { "Name", "Location", "Mode" };
  138. string[] parameterSetNames = { "__AllParameterSets" };
  139. string key = "name";
  140. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  141. {
  142. AllowedValues = new List<object>() { "Mode1", "Mode2", "Mode3" },
  143. MaxLength = "5",
  144. MinLength = "1",
  145. Type = "bool"
  146. };
  147. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  148. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  149. Assert.Equal(key + "FromTemplate", dynamicParameter.Name);
  150. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  151. Assert.Equal(typeof(bool), dynamicParameter.ParameterType);
  152. Assert.Equal(2, dynamicParameter.Attributes.Count);
  153. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  154. Assert.True(parameterAttribute.Mandatory);
  155. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  156. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  157. ValidateLengthAttribute validateLengthAttribute = (ValidateLengthAttribute)dynamicParameter.Attributes[1];
  158. Assert.Equal(int.Parse(value.MinLength), validateLengthAttribute.MinLength);
  159. Assert.Equal(int.Parse(value.MaxLength), validateLengthAttribute.MaxLength);
  160. }
  161. [Fact]
  162. [Trait(Category.AcceptanceType, Category.CheckIn)]
  163. public void ConstructsDynamicParameterNoValidation()
  164. {
  165. string[] parameters = { "Name", "Location", "Mode" };
  166. string[] parameterSetNames = { "__AllParameterSets" };
  167. string key = "computeMode";
  168. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  169. {
  170. AllowedValues = new List<object>(),
  171. DefaultValue = "Mode1",
  172. Type = "securestring"
  173. };
  174. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  175. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  176. Assert.Equal("computeMode", dynamicParameter.Name);
  177. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  178. Assert.Equal(typeof(SecureString), dynamicParameter.ParameterType);
  179. Assert.Equal(1, dynamicParameter.Attributes.Count);
  180. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  181. Assert.False(parameterAttribute.Mandatory);
  182. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  183. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  184. }
  185. [Fact]
  186. [Trait(Category.AcceptanceType, Category.CheckIn)]
  187. public void ConstructsDynamicParameterWithNullAllowedValues()
  188. {
  189. string[] parameters = { "Name", "Location", "Mode" };
  190. string[] parameterSetNames = { "__AllParameterSets" };
  191. string key = "computeMode";
  192. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  193. {
  194. AllowedValues = null,
  195. DefaultValue = "Mode1",
  196. Type = "securestring"
  197. };
  198. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  199. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  200. Assert.Equal("computeMode", dynamicParameter.Name);
  201. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  202. Assert.Equal(typeof(SecureString), dynamicParameter.ParameterType);
  203. Assert.Equal(1, dynamicParameter.Attributes.Count);
  204. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  205. Assert.False(parameterAttribute.Mandatory);
  206. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  207. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  208. }
  209. [Fact]
  210. [Trait(Category.AcceptanceType, Category.CheckIn)]
  211. public void ConstructsObjectTypeDynamicParameter()
  212. {
  213. string[] parameters = { "Name", "Location", "Mode" };
  214. string[] parameterSetNames = { "__AllParameterSets" };
  215. string key = "appSku";
  216. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  217. {
  218. AllowedValues = new List<object>()
  219. {
  220. JObject.Parse("{\"code\" : \"F1\", \"name\" : \"Free\"}"),
  221. JObject.Parse("{\"code\" : \"F2\", \"name\" : \"Shared\"}"),
  222. },
  223. DefaultValue = JObject.Parse("{\"code\" : \"F1\", \"name\" : \"Free\"}"),
  224. Type = "object"
  225. };
  226. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  227. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  228. Assert.Equal("appSku", dynamicParameter.Name);
  229. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  230. Assert.Equal(typeof(Hashtable), dynamicParameter.ParameterType);
  231. Assert.Equal(1, dynamicParameter.Attributes.Count);
  232. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  233. Assert.False(parameterAttribute.Mandatory);
  234. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  235. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  236. }
  237. [Fact]
  238. [Trait(Category.AcceptanceType, Category.CheckIn)]
  239. public void ConstructsArrayTypeDynamicParameter()
  240. {
  241. string[] parameters = { "Name", "Location", "Mode" };
  242. string[] parameterSetNames = { "__AllParameterSets" };
  243. string key = "ranks";
  244. TemplateFileParameterV1 value = new TemplateFileParameterV1()
  245. {
  246. AllowedValues = new List<object>()
  247. {
  248. JArray.Parse("[\"1\", \"3\", \"5\"]"),
  249. JArray.Parse("[\"A\", \"D\", \"F\"]"),
  250. },
  251. DefaultValue = JArray.Parse("[\"A\", \"D\", \"F\"]"),
  252. Type = "array"
  253. };
  254. KeyValuePair<string, TemplateFileParameterV1> parameter = new KeyValuePair<string, TemplateFileParameterV1>(key, value);
  255. RuntimeDefinedParameter dynamicParameter = TemplateUtility.ConstructDynamicParameter(parameters, parameter);
  256. Assert.Equal("ranks", dynamicParameter.Name);
  257. Assert.Equal(value.DefaultValue, dynamicParameter.Value);
  258. Assert.Equal(typeof(object[]), dynamicParameter.ParameterType);
  259. Assert.Equal(1, dynamicParameter.Attributes.Count);
  260. ParameterAttribute parameterAttribute = (ParameterAttribute)dynamicParameter.Attributes[0];
  261. Assert.False(parameterAttribute.Mandatory);
  262. Assert.True(parameterAttribute.ValueFromPipelineByPropertyName);
  263. Assert.Equal(parameterSetNames[0], parameterAttribute.ParameterSetName);
  264. }
  265. [Fact]
  266. [Trait(Category.AcceptanceType, Category.CheckIn)]
  267. public void GetsDynamicParametersForTemplateFile()
  268. {
  269. RuntimeDefinedParameterDictionary result = TemplateUtility.GetTemplateParametersFromFile(
  270. templateFile,
  271. null,
  272. null,
  273. new[] { "TestPS" });
  274. Assert.Equal(7, result.Count);
  275. Assert.Equal("string", result["string"].Name);
  276. Assert.Equal(typeof(string), result["String"].ParameterType);
  277. Assert.Equal("int", result["int"].Name);
  278. Assert.Equal(typeof(int), result["int"].ParameterType);
  279. Assert.Equal("securestring", result["securestring"].Name);
  280. Assert.Equal(typeof(SecureString), result["securestring"].ParameterType);
  281. Assert.Equal("bool", result["bool"].Name);
  282. Assert.Equal(typeof(bool), result["bool"].ParameterType);
  283. Assert.Equal("object", result["object"].Name);
  284. Assert.Equal(typeof(Hashtable), result["object"].ParameterType);
  285. Assert.Equal("secureObject", result["secureObject"].Name);
  286. Assert.Equal(typeof(Hashtable), result["secureObject"].ParameterType);
  287. Assert.Equal("array", result["array"].Name);
  288. Assert.Equal(typeof(object[]), result["array"].ParameterType);
  289. }
  290. [Fact]
  291. [Trait(Category.AcceptanceType, Category.CheckIn)]
  292. public void GetTemplateParametersFromObject()
  293. {
  294. Hashtable templateParameterObject = new Hashtable();
  295. templateParameterObject["string"] = "myvalue";
  296. templateParameterObject["int"] = 12;
  297. templateParameterObject["bool"] = true;
  298. templateParameterObject["object"] = new Hashtable()
  299. {
  300. { "code", "F1" },
  301. { "name", "Free" }
  302. };
  303. templateParameterObject["array"] = new object[] {
  304. "A", "D", "F"
  305. };
  306. RuntimeDefinedParameterDictionary result = TemplateUtility.GetTemplateParametersFromFile(
  307. templateFile,
  308. templateParameterObject,
  309. null,
  310. new[] { "TestPS" });
  311. Assert.Equal(7, result.Count);
  312. Assert.Equal("string", result["string"].Name);
  313. Assert.Equal(typeof(string), result["string"].ParameterType);
  314. Assert.Equal("myvalue", result["string"].Value);
  315. Assert.Equal("int", result["int"].Name);
  316. Assert.Equal(typeof(int), result["int"].ParameterType);
  317. Assert.Equal(12, result["int"].Value);
  318. Assert.Equal("bool", result["bool"].Name);
  319. Assert.Equal(typeof(bool), result["bool"].ParameterType);
  320. Assert.Equal(true, result["bool"].Value);
  321. Assert.Equal("object", result["object"].Name);
  322. Assert.Equal(typeof(Hashtable), result["object"].ParameterType);
  323. Hashtable objectValue = result["object"].Value as Hashtable;
  324. Assert.Equal(2, objectValue.Count);
  325. Assert.Equal("F1", objectValue["code"]);
  326. Assert.Equal("Free", objectValue["name"]);
  327. Assert.Equal("array", result["array"].Name);
  328. Assert.Equal(typeof(object[]), result["array"].ParameterType);
  329. var arrayValue = result["array"].Value as object[];
  330. Assert.Equal(3, arrayValue.Length);
  331. Assert.Equal("A", arrayValue[0]);
  332. Assert.Equal("F", arrayValue[2]);
  333. }
  334. [Fact]
  335. [Trait(Category.AcceptanceType, Category.CheckIn)]
  336. public void GetTemplateParametersFromFileMergesObjects()
  337. {
  338. Hashtable hashtable = new Hashtable();
  339. hashtable["Bool"] = true;
  340. hashtable["Foo"] = "bar";
  341. RuntimeDefinedParameterDictionary result = TemplateUtility.GetTemplateParametersFromFile(
  342. templateFile,
  343. null,
  344. templateParameterFileSchema1,
  345. new[] { "TestPS" });
  346. Assert.Equal(7, result.Count);
  347. Assert.Equal("string", result["string"].Name);
  348. Assert.Equal(typeof(string), result["string"].ParameterType);
  349. Assert.Equal("myvalue", result["string"].Value);
  350. Assert.Equal("int", result["int"].Name);
  351. Assert.Equal(typeof(int), result["int"].ParameterType);
  352. Assert.Equal((System.Int64)12, result["int"].Value);
  353. Assert.Equal("bool", result["bool"].Name);
  354. Assert.Equal(typeof(bool), result["bool"].ParameterType);
  355. Assert.Equal(true, result["bool"].Value);
  356. Assert.Equal("object", result["object"].Name);
  357. Assert.Equal(typeof(Hashtable), result["object"].ParameterType);
  358. JObject objectValue = result["object"].Value as JObject;
  359. Assert.Equal(2, objectValue.Count);
  360. Assert.Equal("F1", objectValue["code"].ToObject<string>());
  361. Assert.Equal("Free", objectValue["name"].ToObject<string>());
  362. Assert.Equal("array", result["array"].Name);
  363. Assert.Equal(typeof(object[]), result["array"].ParameterType);
  364. var arrayValue = result["array"].Value as JArray;
  365. Assert.Equal(3, arrayValue.Count);
  366. Assert.Equal("A", arrayValue[0].ToObject<string>());
  367. Assert.Equal("F", arrayValue[2].ToObject<string>());
  368. }
  369. [Fact]
  370. [Trait(Category.AcceptanceType, Category.CheckIn)]
  371. public void GetTemplateParametersFromFileWithSchema2MergesObjects()
  372. {
  373. Hashtable hashtable = new Hashtable();
  374. hashtable["Bool"] = true;
  375. hashtable["Foo"] = "bar";
  376. RuntimeDefinedParameterDictionary result = TemplateUtility.GetTemplateParametersFromFile(
  377. templateFile,
  378. null,
  379. templateParameterFileSchema2,
  380. new[] { "TestPS" });
  381. Assert.Equal(7, result.Count);
  382. Assert.Equal("string", result["string"].Name);
  383. Assert.Equal(typeof(string), result["string"].ParameterType);
  384. Assert.Equal("myvalue", result["string"].Value);
  385. Assert.Equal("int", result["int"].Name);
  386. Assert.Equal(typeof(int), result["int"].ParameterType);
  387. Assert.Equal("12", result["int"].Value);
  388. Assert.Equal("bool", result["bool"].Name);
  389. Assert.Equal(typeof(bool), result["bool"].ParameterType);
  390. Assert.Equal("True", result["bool"].Value);
  391. Assert.Equal("object", result["object"].Name);
  392. Assert.Equal(typeof(Hashtable), result["object"].ParameterType);
  393. JObject objectValue = result["object"].Value as JObject;
  394. Assert.Equal(2, objectValue.Count);
  395. Assert.Equal("F1", objectValue["code"].ToObject<string>());
  396. Assert.Equal("Free", objectValue["name"].ToObject<string>());
  397. Assert.Equal("array", result["array"].Name);
  398. Assert.Equal(typeof(object[]), result["array"].ParameterType);
  399. var arrayValue = result["array"].Value as JArray;
  400. Assert.Equal(3, arrayValue.Count);
  401. Assert.Equal("A", arrayValue[0].ToObject<string>());
  402. Assert.Equal("F", arrayValue[2].ToObject<string>());
  403. }
  404. [Fact]
  405. [Trait(Category.AcceptanceType, Category.CheckIn)]
  406. public void HandlesInvalidTemplateFiles()
  407. {
  408. Hashtable hashtable = new Hashtable();
  409. hashtable["Bool"] = true;
  410. hashtable["Foo"] = "bar";
  411. RuntimeDefinedParameterDictionary result = TemplateUtility.GetTemplateParametersFromFile(
  412. invalidTemplateFile,
  413. null,
  414. templateParameterFileSchema1,
  415. new[] { "TestPS" });
  416. Assert.Equal(0, result.Count);
  417. }
  418. [Fact]
  419. [Trait(Category.AcceptanceType, Category.CheckIn)]
  420. public void ParseTemplateParameterFileContents_DeserializeWithCorrectType()
  421. {
  422. Dictionary<string, TemplateFileParameterV1> result =
  423. TemplateUtility.ParseTemplateParameterFileContents(@"Resources\WebSite.param.dev.json");
  424. Assert.Equal(true, result["isWorker"].Value);
  425. Assert.Equal((System.Int64)1, result["numberOfWorker"].Value);
  426. }
  427. }
  428. }