Skip to content

Commit 4b49081

Browse files
committed
Merge pull request #2 from TianoMS/MoveRG
Fix resources test cases.
2 parents 7595081 + 41fe06f commit 4b49081

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/ResourceGroupDeployments/RemoveAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System.Management.Automation;
1516
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation;
1617
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
1718
using Microsoft.Azure.ServiceManagemenet.Common.Models;
1819
using Moq;
19-
using System.Management.Automation;
20-
using System.Management.Automation;
2120
using Xunit;
2221
using Xunit.Abstractions;
2322

@@ -51,14 +50,15 @@ public RemoveAzureResourceGroupDeploymentCommandTests(ITestOutputHelper output)
5150
public void RemoveDeployment()
5251
{
5352
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
53+
resourcesClientMock.Setup(f => f.DeleteDeployment(resourceGroupName, deploymentName));
5454

5555
cmdlet.ResourceGroupName = resourceGroupName;
5656
cmdlet.Name = deploymentName;
5757
cmdlet.Force = true;
5858

5959
cmdlet.ExecuteCmdlet();
6060

61-
commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
61+
resourcesClientMock.Verify(f => f.DeleteDeployment(resourceGroupName, deploymentName), Times.Once());
6262
}
6363
}
6464
}

src/ResourceManager/Resources/Commands.Resources.Test/ResourceGroupDeployments/StopAzureResourceGroupDeploymentCommandTests.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
//using Microsoft.Azure.Commands.Common.Test.Mocks;
15+
using System.Management.Automation;
1616
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation;
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
18-
using Microsoft.Azure.Commands.ScenarioTest;
1918
using Microsoft.Azure.ServiceManagemenet.Common.Models;
20-
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
21-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2219
using Moq;
23-
using System.Management.Automation;
24-
using System.Management.Automation;
2520
using Xunit;
2621
using Xunit.Abstractions;
2722

23+
2824
namespace Microsoft.Azure.Commands.Resources.Test.Resources
2925
{
3026
public class StopAzureResourceGroupDeploymentCommandTests
@@ -34,37 +30,36 @@ public class StopAzureResourceGroupDeploymentCommandTests
3430
private Mock<ResourceManagerSdkClient> resourcesClientMock;
3531

3632
private Mock<ICommandRuntime> commandRuntimeMock;
37-
private MockCommandRuntime mockRuntime;
3833

3934
private string resourceGroupName = "myResourceGroup";
4035

36+
private string deploymentName = "myDeployment";
37+
4138
public StopAzureResourceGroupDeploymentCommandTests(ITestOutputHelper output)
4239
{
4340
resourcesClientMock = new Mock<ResourceManagerSdkClient>();
4441
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
4542
commandRuntimeMock = new Mock<ICommandRuntime>();
4643
cmdlet = new StopAzureResourceGroupDeploymentCmdlet()
4744
{
48-
//CommandRuntime = commandRuntimeMock.Object,
45+
CommandRuntime = commandRuntimeMock.Object,
4946
ResourceManagerSdkClient = resourcesClientMock.Object
5047
};
51-
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
52-
mockRuntime = new MockCommandRuntime();
53-
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
54-
5548
}
5649

5750
[Fact]
5851
public void StopsActiveDeployment()
5952
{
6053
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
54+
resourcesClientMock.Setup(f => f.CancelDeployment(resourceGroupName, deploymentName));
6155

6256
cmdlet.ResourceGroupName = resourceGroupName;
57+
cmdlet.Name = deploymentName;
6358
cmdlet.Force = true;
6459

6560
cmdlet.ExecuteCmdlet();
6661

67-
commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
62+
resourcesClientMock.Verify(f => f.CancelDeployment(resourceGroupName, deploymentName), Times.Once());
6863
}
6964
}
7065
}

0 commit comments

Comments
 (0)