|
36 | 36 | using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
|
37 | 37 | using Moq;
|
38 | 38 | using Newtonsoft.Json;
|
| 39 | +using Newtonsoft.Json.Linq; |
39 | 40 | using Xunit;
|
40 | 41 |
|
41 | 42 | namespace Microsoft.Azure.Commands.Resources.Test.Models
|
@@ -329,6 +330,43 @@ public void TestTemplateShowsSuccessMessage()
|
329 | 330 | progressLoggerMock.Verify(f => f("Template is valid."), Times.Once());
|
330 | 331 | }
|
331 | 332 |
|
| 333 | + [Fact] |
| 334 | + [Trait(Category.AcceptanceType, Category.CheckIn)] |
| 335 | + public void TestTemplateShowsSuccessMessageWithObjectAsResponse() |
| 336 | + { |
| 337 | + Uri templateUri = new Uri("http://templateuri.microsoft.com"); |
| 338 | + Deployment deploymentFromValidate = new Deployment(); |
| 339 | + PSDeploymentCmdletParameters parameters = new PSDeploymentCmdletParameters() |
| 340 | + { |
| 341 | + ScopeType = DeploymentScopeType.ResourceGroup, |
| 342 | + ResourceGroupName = resourceGroupName, |
| 343 | + DeploymentMode = DeploymentMode.Incremental, |
| 344 | + TemplateFile = templateFile, |
| 345 | + }; |
| 346 | + resourceGroupMock.Setup(f => f.CheckExistenceWithHttpMessagesAsync(parameters.ResourceGroupName, null, new CancellationToken())) |
| 347 | + .Returns(Task.Factory.StartNew(() => CreateAzureOperationResponse(true))); |
| 348 | + |
| 349 | + deploymentsMock.Setup(f => f.ValidateWithHttpMessagesAsync(resourceGroupName, It.IsAny<string>(), It.IsAny<Deployment>(), null, new CancellationToken())) |
| 350 | + .Returns(Task.Factory.StartNew(() => |
| 351 | + { |
| 352 | + |
| 353 | + var result = new AzureOperationResponse<object>() |
| 354 | + { |
| 355 | + Body = new JObject(new JProperty("id", "DeploymentId")) |
| 356 | + }; |
| 357 | + |
| 358 | + result.Response = new System.Net.Http.HttpResponseMessage(); |
| 359 | + result.Response.StatusCode = HttpStatusCode.Accepted; |
| 360 | + |
| 361 | + return result; |
| 362 | + })) |
| 363 | + .Callback((string rg, string dn, Deployment d, Dictionary<string, List<string>> customHeaders, CancellationToken c) => { deploymentFromValidate = d; }); |
| 364 | + |
| 365 | + TemplateValidationInfo error = resourcesClient.ValidateDeployment(parameters); |
| 366 | + Assert.Empty(error.Errors); |
| 367 | + progressLoggerMock.Verify(f => f("Template is valid."), Times.Once()); |
| 368 | + } |
| 369 | + |
332 | 370 | [Fact]
|
333 | 371 | [Trait(Category.AcceptanceType, Category.CheckIn)]
|
334 | 372 | public void TestTemplateShowsSuccessMessageWithDiagnostics()
|
|
0 commit comments