Skip to content

Commit 3780fa1

Browse files
committed
addressed the revew comments
1 parent a65b38b commit 3780fa1

File tree

14 files changed

+166
-79
lines changed

14 files changed

+166
-79
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/ActionGroups/GetAzureRmActionGroupCommandTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void GetActionGroupCommandParametersProcessing()
9393
cmdlet.ExecuteCmdlet();
9494

9595
// Get by resource group
96-
cmdlet.ResourceGroup = Utilities.ResourceGroup;
96+
cmdlet.ResourceGroupName = Utilities.ResourceGroup;
9797
cmdlet.ExecuteCmdlet();
9898

9999
Assert.Equal(Utilities.ResourceGroup, this.resourceGroup);
@@ -107,7 +107,7 @@ public void GetActionGroupCommandParametersProcessing()
107107
Assert.Equal(Utilities.Name, this.name);
108108

109109
// Error
110-
cmdlet.ResourceGroup = " ";
110+
cmdlet.ResourceGroupName = " ";
111111
cmdlet.Name = Utilities.Name;
112112
Assert.Throws<PSArgumentException>(() => cmdlet.ExecuteCmdlet());
113113
}

src/ResourceManager/Insights/Commands.Insights.Test/ActionGroups/NewAzureRmActionGroupReceiverCommandTests.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
namespace Microsoft.Azure.Commands.Insights.Test.ActionGroups
2222
{
23+
using System;
24+
25+
using Microsoft.Azure.Commands.Insights.OutputClasses;
2326
using Microsoft.Azure.Management.Monitor.Management.Models;
2427

2528
public class NewAzureRmActionGroupReceiverTests
@@ -41,30 +44,59 @@ public NewAzureRmActionGroupReceiverTests(Xunit.Abstractions.ITestOutputHelper o
4144
[Trait(Category.AcceptanceType, Category.CheckIn)]
4245
public void NewAzureRmReceiverCommandEmailParametersProcessing()
4346
{
44-
Cmdlet.Type = "email";
47+
Cmdlet.EmailReceiver = true;
4548
Cmdlet.Name = "email1";
4649
Cmdlet.EmailAddress = "[email protected]";
4750
Cmdlet.ExecuteCmdlet();
51+
52+
Func<PSEmailReceiver, bool> verify = r =>
53+
{
54+
Assert.Equal("[email protected]", r.EmailAddress);
55+
Assert.Equal("email1", r.Name);
56+
return true;
57+
};
58+
59+
this.commandRuntimeMock.Verify(o => o.WriteObject(It.Is<PSEmailReceiver>(r => verify(r))), Times.Once);
4860
}
4961

5062
[Fact]
5163
[Trait(Category.AcceptanceType, Category.CheckIn)]
5264
public void NewAzureRmReceiverCommandSmsParametersProcessing()
5365
{
54-
Cmdlet.Type = "sms";
66+
Cmdlet.SmsReceiver = true;
5567
Cmdlet.Name = "sms1";
5668
Cmdlet.CountryCode = "1";
5769
Cmdlet.PhoneNumber = "4254251234";
70+
Cmdlet.ExecuteCmdlet();
71+
72+
Func<PSSmsReceiver, bool> verify = r =>
73+
{
74+
Assert.Equal("1", r.CountryCode);
75+
Assert.Equal("4254251234", r.PhoneNumber);
76+
Assert.Equal("sms1", r.Name);
77+
return true;
78+
};
79+
80+
this.commandRuntimeMock.Verify(o => o.WriteObject(It.Is<PSSmsReceiver>(r => verify(r))), Times.Once);
5881
}
5982

6083
[Fact]
6184
[Trait(Category.AcceptanceType, Category.CheckIn)]
6285
public void NewAzureRmReceiverCommandWebhookParametersProcessing()
6386
{
64-
Cmdlet.Type = "webhook";
87+
Cmdlet.WebhookReceiver = true;
6588
Cmdlet.Name = "webhook1";
6689
Cmdlet.ServiceUri = "http://test.com";
6790
Cmdlet.ExecuteCmdlet();
91+
92+
Func<PSWebhookReceiver, bool> verify = r =>
93+
{
94+
Assert.Equal("http://test.com", r.ServiceUri);
95+
Assert.Equal("webhook1", r.Name);
96+
return true;
97+
};
98+
99+
this.commandRuntimeMock.Verify(o => o.WriteObject(It.Is<PSWebhookReceiver>(r => verify(r))), Times.Once);
68100
}
69101
}
70102
}

src/ResourceManager/Insights/Commands.Insights.Test/ActionGroups/RemoveAzureRmActionGroupCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public RemoveAzureRmActionGroupTests(Xunit.Abstractions.ITestOutputHelper output
6969
[Trait(Category.AcceptanceType, Category.CheckIn)]
7070
public void RemoveActionGroupCommandParametersProcessing()
7171
{
72-
cmdlet.ResourceGroup = Utilities.ResourceGroup;
72+
cmdlet.ResourceGroupName = Utilities.ResourceGroup;
7373
cmdlet.Name = "group1";
7474
cmdlet.ExecuteCmdlet();
7575

src/ResourceManager/Insights/Commands.Insights.Test/ActionGroups/SetAzureRmActionGroupCommandTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public AddAzureRmActionGroupTests(Xunit.Abstractions.ITestOutputHelper output)
8181
public void SetActionGroupCommandParametersProcessing()
8282
{
8383
cmdlet.Name = "ActionGroupName";
84-
cmdlet.ResourceGroup = Utilities.ResourceGroup;
84+
cmdlet.ResourceGroupName = Utilities.ResourceGroup;
8585
cmdlet.ShortName = "AgShortName";
8686
cmdlet.Receiver = new List<PSActionGroupReceiverBase>
8787
{
@@ -121,7 +121,7 @@ public void SetActionGroupCommandParametersProcessing()
121121
Assert.Null(this.createOrUpdatePrms.Tags);
122122

123123
cmdlet.DisableGroup = true;
124-
cmdlet.Tags = new Dictionary<string, string>();
124+
cmdlet.Tag = new Dictionary<string, string>();
125125
cmdlet.ExecuteCmdlet();
126126

127127
Assert.False(this.createOrUpdatePrms.Enabled);

src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/ActionGroupsTests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ function Test-AddGetListSetRemoveActionGroup
2828
try
2929
{
3030
Write-Verbose " ****** Creating a new email receiver"
31-
$email1 = New-AzureRmActionGroupReceiver -Type 'email' -Name 'emailreceiver' -EmailAddress '[email protected]'
31+
$email1 = New-AzureRmActionGroupReceiver -EmailReceiver -Name 'emailreceiver' -EmailAddress '[email protected]'
3232
Assert-NotNull $email1
3333
Assert-AreEqual 'emailreceiver' $email1.Name
3434
Assert-AreEqual '[email protected]' $email1.EmailAddress
3535

3636
Write-Verbose " ****** Creating a new sms receiver"
37-
$sms1 = New-AzureRmActionGroupReceiver -Type 'sms' -Name 'smsreceiver' -CountryCode '1' -PhoneNumber '7817386781'
37+
$sms1 = New-AzureRmActionGroupReceiver -SmsReceiver -Name 'smsreceiver' -CountryCode '1' -PhoneNumber '4254251234'
3838
Assert-NotNull $sms1
3939
Assert-AreEqual 'smsreceiver' $sms1.Name
4040
Assert-AreEqual '1' $sms1.CountryCode
41-
Assert-AreEqual '7817386781' $sms1.PhoneNumber
41+
Assert-AreEqual '4254251234' $sms1.PhoneNumber
4242

4343
Write-Verbose " ****** Creating a new webhook receiver"
44-
$webhook1 = New-AzureRmActionGroupReceiver -Type 'webhook' -Name 'webhookreceiver' -ServiceUri 'http://test.com'
44+
$webhook1 = New-AzureRmActionGroupReceiver -WebhookReceiver -Name 'webhookreceiver' -ServiceUri 'http://test.com'
4545
Assert-NotNull $webhook1
4646
Assert-AreEqual 'webhookreceiver' $webhook1.Name
4747
Assert-AreEqual 'http://test.com' $webhook1.ServiceUri
@@ -64,7 +64,7 @@ function Test-AddGetListSetRemoveActionGroup
6464
Assert-AreEqual $actionGroupName $retrieved[0].Name
6565

6666
Write-Verbose " ****** Getting the action group by resource group"
67-
$retrieved = Get-AzureRmActionGroup -ResourceGroup $resourceGroupName
67+
$retrieved = Get-AzureRmActionGroup -ResourceGroupName $resourceGroupName
6868
Assert-NotNull $retrieved
6969
Assert-AreEqual 1 $retrieved.Length
7070
Assert-AreEqual $actionGroupName $retrieved[0].Name

src/ResourceManager/Insights/Commands.Insights.Test/SessionRecords/Microsoft.Azure.Commands.Insights.Test.ScenarioTests.ActionGroupsTests/TestAddGetListSetRemoveActionGroup.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"RequestUri": "/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse?api-version=2017-04-01",
5959
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMDdjMGIwOWQtOWY2OS00ZTZlLThkMDUtZjU5ZjY3Mjk5Y2IyL3Jlc291cmNlR3JvdXBzL0RlZmF1bHQtQWN0aXZpdHlMb2dBbGVydHMvcHJvdmlkZXJzL21pY3Jvc29mdC5pbnNpZ2h0cy9hY3Rpb25Hcm91cHMvYW5keWdyb3VwLWRvbm90dXNlP2FwaS12ZXJzaW9uPTIwMTctMDQtMDE=",
6060
"RequestMethod": "PUT",
61-
"RequestBody": "{\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"7817386781\"\r\n }\r\n ]\r\n },\r\n \"location\": \"Global\",\r\n \"tags\": {}\r\n}",
61+
"RequestBody": "{\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4254251234\"\r\n }\r\n ]\r\n },\r\n \"location\": \"Global\",\r\n \"tags\": {}\r\n}",
6262
"RequestHeaders": {
6363
"Content-Type": [
6464
"application/json; charset=utf-8"
@@ -79,7 +79,7 @@
7979
"Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.17.0.0"
8080
]
8181
},
82-
"ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"7817386781\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": [\r\n {\r\n \"name\": \"webhookreceiver\",\r\n \"serviceUri\": \"http://test.com\"\r\n }\r\n ]\r\n },\r\n \"identity\": null\r\n}",
82+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4254251234\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": [\r\n {\r\n \"name\": \"webhookreceiver\",\r\n \"serviceUri\": \"http://test.com\"\r\n }\r\n ]\r\n },\r\n \"identity\": null\r\n}",
8383
"ResponseHeaders": {
8484
"Content-Length": [
8585
"578"
@@ -139,7 +139,7 @@
139139
"Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.17.0.0"
140140
]
141141
},
142-
"ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"7817386781\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n}",
142+
"ResponseBody": "{\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4254251234\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n}",
143143
"ResponseHeaders": {
144144
"Content-Length": [
145145
"578"
@@ -199,7 +199,7 @@
199199
"Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.17.0.0"
200200
]
201201
},
202-
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"7817386781\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n },\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-EastUS/providers/microsoft.insights/actionGroups/nj\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"nj\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"nj\",\r\n \"enabled\": true,\r\n \"emailReceivers\": [],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"jaga-sms\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4253011342\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n }\r\n ]\r\n}",
202+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4254251234\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n },\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-Storage-EastUS/providers/microsoft.insights/actionGroups/nj\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"nj\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"nj\",\r\n \"enabled\": true,\r\n \"emailReceivers\": [],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"jaga-sms\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4253011342\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n }\r\n ]\r\n}",
203203
"ResponseHeaders": {
204204
"Content-Length": [
205205
"1040"
@@ -259,7 +259,7 @@
259259
"Microsoft.Azure.Management.Monitor.Management.MonitorManagementClient/0.17.0.0"
260260
]
261261
},
262-
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"7817386781\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n }\r\n ]\r\n}",
262+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/07c0b09d-9f69-4e6e-8d05-f59f67299cb2/resourceGroups/Default-ActivityLogAlerts/providers/microsoft.insights/actionGroups/andygroup-donotuse\",\r\n \"type\": \"Microsoft.Insights/ActionGroups\",\r\n \"name\": \"andygroup-donotuse\",\r\n \"location\": \"Global\",\r\n \"kind\": null,\r\n \"tags\": {},\r\n \"properties\": {\r\n \"groupShortName\": \"andygroup\",\r\n \"enabled\": false,\r\n \"emailReceivers\": [\r\n {\r\n \"name\": \"emailreceiver\",\r\n \"emailAddress\": \"[email protected]\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"smsReceivers\": [\r\n {\r\n \"name\": \"smsreceiver\",\r\n \"countryCode\": \"1\",\r\n \"phoneNumber\": \"4254251234\",\r\n \"status\": \"Enabled\"\r\n }\r\n ],\r\n \"webhookReceivers\": []\r\n },\r\n \"identity\": null\r\n }\r\n ]\r\n}",
263263
"ResponseHeaders": {
264264
"Content-Length": [
265265
"590"

0 commit comments

Comments
 (0)