Skip to content

Commit 3a634d6

Browse files
committed
Fix resources test cases.
1 parent fdb54a8 commit 3a634d6

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
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 Moq;
18-
using System.Management.Automation;
1919
using Xunit;
2020

2121
namespace Microsoft.Azure.Commands.Resources.Test.Resources
@@ -47,14 +47,15 @@ public RemoveAzureResourceGroupDeploymentCommandTests()
4747
public void RemoveDeployment()
4848
{
4949
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
50-
50+
resourcesClientMock.Setup(f => f.DeleteDeployment(resourceGroupName, deploymentName));
51+
5152
cmdlet.ResourceGroupName = resourceGroupName;
5253
cmdlet.Name = deploymentName;
5354
cmdlet.Force = true;
5455

5556
cmdlet.ExecuteCmdlet();
5657

57-
commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
58+
resourcesClientMock.Verify(f => f.DeleteDeployment(resourceGroupName, deploymentName), Times.Once());
5859
}
5960
}
6061
}

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@
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;
19-
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
20-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2118
using Moq;
22-
using System.Management.Automation;
2319
using Xunit;
2420

2521
namespace Microsoft.Azure.Commands.Resources.Test.Resources
@@ -31,36 +27,35 @@ public class StopAzureResourceGroupDeploymentCommandTests
3127
private Mock<ResourceManagerSdkClient> resourcesClientMock;
3228

3329
private Mock<ICommandRuntime> commandRuntimeMock;
34-
private MockCommandRuntime mockRuntime;
3530

3631
private string resourceGroupName = "myResourceGroup";
3732

33+
private string deploymentName = "myDeployment";
34+
3835
public StopAzureResourceGroupDeploymentCommandTests()
3936
{
4037
resourcesClientMock = new Mock<ResourceManagerSdkClient>();
4138
commandRuntimeMock = new Mock<ICommandRuntime>();
4239
cmdlet = new StopAzureResourceGroupDeploymentCmdlet()
4340
{
44-
//CommandRuntime = commandRuntimeMock.Object,
41+
CommandRuntime = commandRuntimeMock.Object,
4542
ResourceManagerSdkClient = resourcesClientMock.Object
4643
};
47-
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
48-
mockRuntime = new MockCommandRuntime();
49-
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
50-
5144
}
5245

5346
[Fact]
5447
public void StopsActiveDeployment()
5548
{
5649
commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
57-
50+
resourcesClientMock.Setup(f => f.CancelDeployment(resourceGroupName, deploymentName));
51+
5852
cmdlet.ResourceGroupName = resourceGroupName;
53+
cmdlet.Name = deploymentName;
5954
cmdlet.Force = true;
6055

6156
cmdlet.ExecuteCmdlet();
6257

63-
commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
58+
resourcesClientMock.Verify(f => f.CancelDeployment(resourceGroupName, deploymentName), Times.Once());
6459
}
6560
}
6661
}

0 commit comments

Comments
 (0)