Skip to content

Commit 4bfefe0

Browse files
author
Bhavin Shah
committed
updating tests and adding completer
1 parent 830bcb4 commit 4bfefe0

File tree

46 files changed

+4893
-3221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4893
-3221
lines changed

src/Support/Support.Test/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
//
4646
// You can specify all the values or you can default the Build and Revision Numbers
4747
// by using the '*' as shown below:
48-
[assembly: AssemblyVersion("0.1.0")]
49-
[assembly: AssemblyFileVersion("0.1.0")]
48+
[assembly: AssemblyVersion("1.0.0")]
49+
[assembly: AssemblyFileVersion("1.0.0")]
5050
[assembly: CollectionBehavior(DisableTestParallelization = true)]

src/Support/Support.Test/ScenarioTests/SupportTicketTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,25 @@ public void UpdateAzSupportTicketParentObjectParameterSetUpdateSeverity()
128128
TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzSupportTicketParentObjectParameterSetUpdateSeverity");
129129
}
130130

131+
[Fact]
132+
[Trait(Category.AcceptanceType, Category.CheckIn)]
133+
public void UpdateAzSupportTicketNameParameterSetUpdateSeverity()
134+
{
135+
TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzSupportTicketNameParameterSetUpdateSeverity");
136+
}
137+
131138
[Fact]
132139
[Trait(Category.AcceptanceType, Category.CheckIn)]
133140
public void UpdateAzSupportTicketParentObjectParameterSetUpdateStatus()
134141
{
135142
TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzSupportTicketParentObjectParameterSetUpdateSeverity");
136143
}
144+
145+
[Fact]
146+
[Trait(Category.AcceptanceType, Category.CheckIn)]
147+
public void UpdateAzSupportTicketNameParameterSetUpdateStatus()
148+
{
149+
TestController.NewInstance.RunPowerShellTest(_logger, "Update-AzSupportTicketNameParameterSetUpdateStatus");
150+
}
137151
}
138152
}

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/GetAzSupportTicketCommunicationByNameParameterSet.json

Lines changed: 181 additions & 181 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/GetAzSupportTicketCommunicationByParentObjectParameterSet.json

Lines changed: 178 additions & 178 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/GetAzSupportTicketCommunicationFilterByCommunicationType.json

Lines changed: 250 additions & 250 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/GetAzSupportTicketCommunicationPagingParameters.json

Lines changed: 244 additions & 244 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/NewAzSupportTicketCommunicationNameParameterSet.json

Lines changed: 163 additions & 163 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.CommunicationTests/NewAzSupportTicketCommunicationParentObjectParameterSet.json

Lines changed: 165 additions & 165 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationAllParametersId.json

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationAllParametersNameAlias.json

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationAllParametersResourceId.json

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationParentObjectAllParameters.json

Lines changed: 81 additions & 81 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationParentObjectServiceName.json

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ProblemClassificationTests/GetAzSupportProblemClassificationServiceName.json

Lines changed: 32 additions & 32 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ServiceTests/GetAzSupportServiceByNameParameterSetUsingCompleteResourceId.json

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ServiceTests/GetAzSupportServiceByNameParameterSetUsingId.json

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ServiceTests/GetAzSupportServiceByNameParameterSetUsingNameAlias.json

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.ServiceTests/GetAzSupportServiceNoParameter.json

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/GetAzSupportTicketByNameParameterSet.json

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/GetAzSupportTicketFilterByStatus.json

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/GetAzSupportTicketPagingParameters.json

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketQuotaWithContactDetail.json

Lines changed: 101 additions & 101 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketQuotaWithContactObject.json

Lines changed: 99 additions & 99 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketTechnicalWithContactDetail.json

Lines changed: 241 additions & 241 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketTechnicalWithContactObject.json

Lines changed: 238 additions & 238 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketWithContactDetail.json

Lines changed: 97 additions & 97 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/NewAzSupportTicketWithContactObject.json

Lines changed: 97 additions & 97 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketNameParameterSetUpdateSeverity.json

Lines changed: 137 additions & 137 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketNameParameterSetUpdateStatus.json

Lines changed: 525 additions & 0 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketNameParameterSetWithContactDetail.json

Lines changed: 133 additions & 133 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketNameParameterSetWithContactObject.json

Lines changed: 133 additions & 133 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketParentObjectParameterSetUpdateSeverity.json

Lines changed: 525 additions & 0 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketParentObjectParameterSetUpdateStatus.json

Lines changed: 525 additions & 0 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketParentObjectParameterSetWithContactDetail.json

Lines changed: 130 additions & 130 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/SessionRecords/Microsoft.Azure.Commands.Support.Test.ScenarioTests.SupportTicketTests/UpdateAzSupportTicketParentObjectParameterSetWithContactObject.json

Lines changed: 131 additions & 131 deletions
Large diffs are not rendered by default.

src/Support/Support.Test/Support.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Azure.Management.Support" Version="1.0.0-preview.1" />
11+
<PackageReference Include="Microsoft.Azure.Management.Support" Version="1.0.0" />
1212
</ItemGroup>
1313

1414
</Project>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using Microsoft.Azure.Commands.Common.Authentication;
2+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
3+
using Microsoft.Azure.Commands.Support.Helpers;
4+
using Microsoft.Azure.Commands.Support.Models;
5+
using Microsoft.Azure.Management.Support;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using System.Management.Automation;
10+
11+
namespace Microsoft.Azure.PowerShell.Cmdlets.Support.ArgumentCompleters
12+
{
13+
public class ServiceIdCompleter : ArgumentCompleterAttribute
14+
{
15+
private static int _timeout = 3;
16+
17+
public ServiceIdCompleter() : base(CreateScriptBlock())
18+
{
19+
}
20+
21+
public static PSSupportService[] FindResources()
22+
{
23+
try
24+
{
25+
var ids = GetServices();
26+
27+
return ids.ToArray();
28+
}
29+
catch (Exception)
30+
{
31+
}
32+
33+
return new PSSupportService[0];
34+
}
35+
36+
public static List<PSSupportService> GetServices()
37+
{
38+
var context = AzureRmProfileProvider.Instance?.Profile?.DefaultContext;
39+
var supportClient = AzureSession.Instance.ClientFactory.CreateArmClient<MicrosoftSupportClient>(context, AzureEnvironment.Endpoint.ResourceManager);
40+
41+
var allProviders = supportClient.Services.ListAsync();
42+
43+
var timeoutDuration = TimeSpan.FromSeconds(_timeout);
44+
var hasNotTimedOut = allProviders.Wait(timeoutDuration);
45+
var hasResult = allProviders.Result != null;
46+
var isSuccessful = hasNotTimedOut && hasResult;
47+
48+
return isSuccessful
49+
? allProviders.Result.Select(resource => resource.ToPSSupportService()).ToList()
50+
: new List<PSSupportService>();
51+
}
52+
53+
54+
/// <summary>
55+
/// Create ScriptBlock that registers the correct location for tab completetion of the -Location parameter
56+
/// </summary>
57+
/// <param name="resourceTypes"></param>
58+
/// <returns></returns>
59+
public static ScriptBlock CreateScriptBlock()
60+
{
61+
string script = "param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)\n";
62+
63+
script += "$resources = [Microsoft.Azure.PowerShell.Cmdlets.Support.ArgumentCompleters.ServiceIdCompleter]::FindResources()\n" +
64+
"$resources | Where-Object { $_.DisplayName -Like \"$wordToComplete*\" } | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_.Id, $_.DisplayName, 'ParameterValue', $_.DisplayName) }";
65+
ScriptBlock scriptBlock = ScriptBlock.Create(script);
66+
return scriptBlock;
67+
}
68+
}
69+
}

src/Support/Support/ChangeLog.md

Lines changed: 11 additions & 0 deletions

src/Support/Support/Models/Enums.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public enum Severity
2828
HighestCriticalImpact
2929
}
3030

31-
public enum TicketStatus
31+
public enum Status
3232
{
3333
Open,
3434
Closed

src/Support/Support/Models/PSSupportService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public class PSSupportService
4343
/// <summary>
4444
/// Gets or sets resource types
4545
/// </summary>
46-
[Ps1Xml(Target = ViewControl.Table)]
4746
public string[] ResourceTypes { get; set; }
4847
}
4948
}

src/Support/Support/ProblemClassifications/GetAzSupportProblemClassification.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Azure.Graph.RBAC.Version1_6;
2020
using Microsoft.Azure.Management.Support;
2121
using Microsoft.Azure.Management.Support.Models;
22+
using Microsoft.Azure.PowerShell.Cmdlets.Support.ArgumentCompleters;
2223
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2324
using System.Linq;
2425
using System.Management.Automation;
@@ -31,6 +32,7 @@ public class GetAzSupportProblemClassification : AzSupportCmdletBase
3132
{
3233
[Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = "Service id for which all problem classifications are retrieved.")]
3334
[Alias("ServiceName")]
35+
[ServiceIdCompleter()]
3436
[ValidateNotNullOrEmpty]
3537
public string ServiceId { get; set; }
3638

src/Support/Support/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
[assembly: ComVisible(false)]
2626
[assembly: CLSCompliant(false)]
2727
[assembly: Guid("22d73af7-38c2-4bf6-b56f-4dc9db05d97a")]
28-
[assembly: AssemblyVersion("0.1.0")]
29-
[assembly: AssemblyFileVersion("0.1.0")]
28+
[assembly: AssemblyVersion("1.0.0")]
29+
[assembly: AssemblyFileVersion("1.0.0")]

src/Support/Support/Services/GetAzSupportService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Azure.Graph.RBAC.Version1_6;
2020
using Microsoft.Azure.Management.Support;
2121
using Microsoft.Azure.Management.Support.Models;
22+
using Microsoft.Azure.PowerShell.Cmdlets.Support.ArgumentCompleters;
2223
using System.Linq;
2324
using System.Management.Automation;
2425
using static Microsoft.Azure.Commands.Support.Helpers.ResourceIdentifierHelper;
@@ -30,6 +31,7 @@ public class GetAzSupportService : AzSupportCmdletBase
3031
{
3132
[Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = "Service id.")]
3233
[Alias("Name")]
34+
[ServiceIdCompleter()]
3335
[ValidateNotNullOrEmpty]
3436
public string Id { get; set; }
3537

src/Support/Support/Support.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Azure.Management.Support" Version="1.0.0-preview.1" />
9+
<PackageReference Include="Microsoft.Azure.Management.Support" Version="1.0.0" />
1010
</ItemGroup>
1111

1212
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />

src/Support/Support/SupportTickets/NewAzSupportTicket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public override void ExecuteCmdlet()
183183

184184
if (!technicalResourceId.Subscription.Equals(this.SupportClient.SubscriptionId, StringComparison.OrdinalIgnoreCase))
185185
{
186-
throw new PSArgumentException(string.Format("TechnicalResourceId {0} does not belong in subscription {1}.", this.TechnicalTicketResourceId, this.SupportClient.SubscriptionId));
186+
throw new PSArgumentException(string.Format("TechnicalResourceId {0} does not belong to subscription {1}.", this.TechnicalTicketResourceId, this.SupportClient.SubscriptionId));
187187
}
188188

189189
var resourceClient = AzureSession.Instance.ClientFactory.CreateArmClient<ResourceManagementClient>(

src/Support/Support/SupportTickets/UpdateAzSupportTicket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class UpdateAzSupportTicket : AzSupportCmdletBase
4242
public Severity Severity { get; set; }
4343

4444
[Parameter(Mandatory = false, HelpMessage = "Update Status of SupportTicket.")]
45-
public TicketStatus Status { get; set; }
45+
public Models.Status Status { get; set; }
4646

4747
[Parameter(Mandatory = true, ParameterSetName = UpdateByNameWithContactObjectParameterSet, HelpMessage = "Update Contact details on SupportTicket.")]
4848
[Parameter(Mandatory = true, ParameterSetName = UpdateByInputObjectWithContactObjectParameterSet, HelpMessage = "Update Contact details on SupportTicket.")]

0 commit comments

Comments
 (0)