Skip to content

Commit

Permalink
Merge pull request #2 from TianoMS/MoveRG
Browse files Browse the repository at this point in the history
Fix resources test cases.
  • Loading branch information
vivsriaus committed May 12, 2016
2 parents 7595081 + 41fe06f commit 4b49081
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Management.Automation;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Moq;
using System.Management.Automation;
using System.Management.Automation;
using Xunit;
using Xunit.Abstractions;

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

cmdlet.ResourceGroupName = resourceGroupName;
cmdlet.Name = deploymentName;
cmdlet.Force = true;

cmdlet.ExecuteCmdlet();

commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
resourcesClientMock.Verify(f => f.DeleteDeployment(resourceGroupName, deploymentName), Times.Once());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

//using Microsoft.Azure.Commands.Common.Test.Mocks;
using System.Management.Automation;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System.Management.Automation;
using System.Management.Automation;
using Xunit;
using Xunit.Abstractions;


namespace Microsoft.Azure.Commands.Resources.Test.Resources
{
public class StopAzureResourceGroupDeploymentCommandTests
Expand All @@ -34,37 +30,36 @@ public class StopAzureResourceGroupDeploymentCommandTests
private Mock<ResourceManagerSdkClient> resourcesClientMock;

private Mock<ICommandRuntime> commandRuntimeMock;
private MockCommandRuntime mockRuntime;

private string resourceGroupName = "myResourceGroup";

private string deploymentName = "myDeployment";

public StopAzureResourceGroupDeploymentCommandTests(ITestOutputHelper output)
{
resourcesClientMock = new Mock<ResourceManagerSdkClient>();
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
commandRuntimeMock = new Mock<ICommandRuntime>();
cmdlet = new StopAzureResourceGroupDeploymentCmdlet()
{
//CommandRuntime = commandRuntimeMock.Object,
CommandRuntime = commandRuntimeMock.Object,
ResourceManagerSdkClient = resourcesClientMock.Object
};
PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
mockRuntime = new MockCommandRuntime();
commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);

}

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

cmdlet.ResourceGroupName = resourceGroupName;
cmdlet.Name = deploymentName;
cmdlet.Force = true;

cmdlet.ExecuteCmdlet();

commandRuntimeMock.Verify(f => f.WriteObject(true), Times.Once());
resourcesClientMock.Verify(f => f.CancelDeployment(resourceGroupName, deploymentName), Times.Once());
}
}
}

0 comments on commit 4b49081

Please sign in to comment.