diff --git a/src/AzurePowershell.sln b/src/AzurePowershell.sln index 50bd4689b675..88b65df2f13a 100644 --- a/src/AzurePowershell.sln +++ b/src/AzurePowershell.sln @@ -1,6 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0MinimumVisualStudioVersion = 10.0.40219.1 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}" ProjectSection(SolutionItems) = preProject local.runsettings = local.runsettings diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTest.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTest.cs index 1ce5f524ca9f..3ecb5cde6f4f 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTest.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTest.cs @@ -626,6 +626,12 @@ public void AzureDeploymentTest() Assert.IsTrue(ce.Message.Contains("The date specified in parameter EndTime is not within the correct range.")); } + // Negative test for Get-AzureVM + var vmRoleList1 = vmPowershellCmdlets.GetAzureVM(); + Assert.IsFalse(vmRoleList1.Any(r => r.DeploymentName == deploymentName)); + var vmRoleList2 = vmPowershellCmdlets.GetAzureVM(serviceName); + Assert.IsFalse(vmRoleList2.Any(r => r.DeploymentName == deploymentName)); + vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true); pass &= Utilities.CheckRemove(vmPowershellCmdlets.GetAzureDeployment, serviceName, DeploymentSlotType.Production); diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs index 9e78bd90c920..37e3a92014b0 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs @@ -1330,9 +1330,9 @@ internal Collection NewAzureVM(string serviceName, S return result; } - public Collection GetAzureVM(string vmName = null) + public Collection GetAzureVM(string serviceName = null) { - return RunPSCmdletAndReturnAll(new GetAzureVMCmdletInfo(vmName, null)); + return RunPSCmdletAndReturnAll(new GetAzureVMCmdletInfo(null, serviceName)); } public SM.PersistentVMRoleContext GetAzureVM(string vmName, string serviceName) diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureVM.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureVM.cs index 9e0062c37ca3..14c372918b8f 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureVM.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureVM.cs @@ -101,14 +101,18 @@ protected override void ExecuteCommand() private List GetVMContextList(string serviceName, NSM.DeploymentGetResponse deployment) where T : PVM.PersistentVMRoleContext, new() { - var vmRoles = new List(deployment.Roles.Where( - r => string.IsNullOrEmpty(Name) - || r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))); + Func typeMatched = + r => string.Equals(r.RoleType, PersistentVMRoleStr, StringComparison.OrdinalIgnoreCase); - return GetVMContextList(serviceName, deployment, vmRoles); + Func nameMatched = + r => string.IsNullOrEmpty(this.Name) || r.RoleName.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase); + + var vmRoles = new List(deployment.Roles.Where(r => typeMatched(r) && nameMatched(r))); + + return CreateVMContextList(serviceName, deployment, vmRoles); } - private List GetVMContextList(string serviceName, NSM.DeploymentGetResponse deployment, List vmRoles) + private List CreateVMContextList(string serviceName, NSM.DeploymentGetResponse deployment, List vmRoles) where T : PVM.PersistentVMRoleContext, new() { var roleContexts = new List();