Skip to content

Commit 7398190

Browse files
committed
Merge pull request #323 from amarzavery/goli
fixing naveen's pr #315
2 parents e7f170f + 42733c1 commit 7398190

File tree

12 files changed

+943
-32
lines changed

12 files changed

+943
-32
lines changed

src/ResourceManager/Websites/Commands.Websites.Test/Commands.Websites.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
<None Include="SessionRecords\Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests\TestCreatesNewSimpleWebApp.json">
132132
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
133133
</None>
134+
<None Include="SessionRecords\Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests\TestSetNewAppServicePlan.json">
135+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
136+
</None>
134137
</ItemGroup>
135138
<ItemGroup>
136139
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/Common.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Gets a website name for testing.
1818
#>
1919
function Get-WebsiteName
2020
{
21-
# need to remove hardcoding
2221
return getAssetName
2322
}
2423

@@ -28,7 +27,6 @@ Gets a website name for testing.
2827
#>
2928
function Get-WebHostPlanName
3029
{
31-
# need to remove hardcoding
3230
return getAssetName
3331
}
3432

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,12 @@ public void TestCreatesNewAppServicePlan()
3333
{
3434
WebsitesController.NewInstance.RunPsTest("Test-CreatesNewAppServicePlan");
3535
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestSetNewAppServicePlan()
40+
{
41+
WebsitesController.NewInstance.RunPsTest("Test-SetNewAppServicePlan");
42+
}
3643
}
3744
}

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.ps1

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,47 @@ function Test-CreatesNewAppServicePlan
7878
Remove-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
7979
Remove-AzureResourceGroup -Name $rgname -Force
8080
}
81+
}
82+
83+
<#
84+
.SYNOPSIS
85+
Tests creating a new Web Hosting Plan.
86+
#>
87+
function Test-SetNewAppServicePlan
88+
{
89+
# Setup
90+
$rgname = Get-ResourceGroupName
91+
$whpName = Get-WebHostPlanName
92+
$location = Get-Location
93+
94+
try
95+
{
96+
#Setup
97+
New-AzureResourceGroup -Name $rgname -Location $location
98+
# Test
99+
$actual = New-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location
100+
$result = Get-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName
101+
# Assert
102+
Assert-AreEqual $whpName $result.WebHostingPlan.Name
103+
Assert-AreEqual 1 $result.WebHostingPlan.Properties.NumberOfWorkers
104+
Assert-AreEqual "Standard" $result.WebHostingPlan.Properties.Sku
105+
Assert-AreEqual "Small" $result.WebHostingPlan.Properties.WorkerSize
106+
107+
# Test setting the created service plan
108+
$newresult = Set-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Sku Premium -NumberofWorkers 12 -WorkerSize Medium
109+
# due to a bug Set and New are not returning the appropriate object so need to get.
110+
$newresult = Get-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName
111+
112+
# Assert
113+
Assert-AreEqual $whpName $result.WebHostingPlan.Name
114+
Assert-AreEqual 12 $newresult.WebHostingPlan.Properties.NumberOfWorkers
115+
Assert-AreEqual "Premium" $newresult.WebHostingPlan.Properties.Sku
116+
Assert-AreEqual "Medium" $newresult.WebHostingPlan.Properties.WorkerSize
117+
}
118+
finally
119+
{
120+
# Cleanup
121+
Remove-AzureAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
122+
Remove-AzureResourceGroup -Name $rgname -Force
123+
}
81124
}

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.WebApp.Test.ScenarioTests.WebAppTests/TestSetNewAppServicePlan.json

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

src/ResourceManager/Websites/Commands.Websites/Cmdlets/AppServicePlan/GetAzureAppServicePlan.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public override void ExecuteCmdlet()
5656

5757
private void GetByWebHostingPlan()
5858
{
59-
WriteObject(WebsitesClient.GetWebHostingPlan(ResourceGroupName, Name));
59+
WriteObject(WebsitesClient.GetAppServicePlan(ResourceGroupName, Name));
6060
}
6161

6262
private void GetByResourceGroup()
6363
{
64-
WriteObject(WebsitesClient.ListWebHostingPlan(ResourceGroupName));
64+
WriteObject(WebsitesClient.ListAppServicePlan(ResourceGroupName));
6565
}
6666
}
6767
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/AppServicePlan/NewAzureAppServicePlan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public override void ExecuteCmdlet()
116116
}
117117
}
118118

119-
WriteObject(WebsitesClient.CreateWebHostingPlan(ResourceGroupName, Name, Location, adminSiteName, NumberofWorkers, skuInput, workerSizeInput));
119+
WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, adminSiteName, NumberofWorkers, skuInput, workerSizeInput));
120120

121121
}
122122

src/ResourceManager/Websites/Commands.Websites/Cmdlets/AppServicePlan/RemoveAppServicePlan.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public override void ExecuteCmdlet()
4848
{
4949
ConfirmAction(
5050
Force.IsPresent,
51-
string.Format(Microsoft.Azure.Commands.WebApp.Properties.Resources.RemovingWebHostPlan, Name),
52-
Microsoft.Azure.Commands.WebApp.Properties.Resources.RemovingWebHostPlan,
51+
string.Format(Microsoft.Azure.Commands.WebApp.Properties.Resources.RemovingAppServicePlan, Name),
52+
Microsoft.Azure.Commands.WebApp.Properties.Resources.RemovingAppServicePlan,
5353
Name,
54-
() => WebsitesClient.RemoveWebHostingPlan(ResourceGroupName, Name));
54+
() => WebsitesClient.RemoveAppServicePlan(ResourceGroupName, Name));
5555
}
5656
}
5757
}

src/ResourceManager/Websites/Commands.Websites/Cmdlets/AppServicePlan/SetAzureAppServicePlan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public override void ExecuteCmdlet()
115115
}
116116
}
117117

118-
WriteObject(WebsitesClient.CreateWebHostingPlan(ResourceGroupName, Name, Location, adminSiteName, NumberofWorkers, skuInput, workerSizeInput));
118+
WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, adminSiteName, NumberofWorkers, skuInput, workerSizeInput));
119119

120120
}
121121

src/ResourceManager/Websites/Commands.Websites/Properties/Resources.Designer.cs

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Websites/Commands.Websites/Properties/Resources.resx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120-
<data name="RemovingWebHostPlan" xml:space="preserve">
121-
<value>Are you sure you want to remove web hosting plan '{0}'</value>
120+
<data name="RemovingAppServicePlan" xml:space="preserve">
121+
<value>Are you sure you want to remove app service plan '{0}'</value>
122122
</data>
123123
<data name="RemoveWebsiteMessage" xml:space="preserve">
124-
<value>Removing website</value>
124+
<value>Removing web app</value>
125125
</data>
126126
<data name="RemoveWebsiteWarning" xml:space="preserve">
127-
<value>Are you sure you want to remove the website "{0}"</value>
127+
<value>Are you sure you want to remove the web app "{0}"</value>
128128
</data>
129129
<data name="RemovingWebsite" xml:space="preserve">
130-
<value>Are you sure you want to remove website '{0}'</value>
130+
<value>Are you sure you want to remove web app '{0}'</value>
131131
</data>
132132
</root>

src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public WebSiteGetHistoricalUsageMetricsResponse GetWebAppUsageMetrics(string res
125125
return usageMetrics;
126126
}
127127

128-
public WebHostingPlanCreateOrUpdateResponse CreateWebHostingPlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize)
128+
public WebHostingPlanCreateOrUpdateResponse CreateAppServicePlan(string resourceGroupName, string whpName, string location, string adminSiteName, int numberOfWorkers, SkuOptions sku, WorkerSizeOptions workerSize)
129129
{
130130
WebHostingPlanProperties webHostingPlanProperties = new WebHostingPlanProperties();
131131
webHostingPlanProperties.Sku = sku;
@@ -143,24 +143,21 @@ public WebHostingPlanCreateOrUpdateResponse CreateWebHostingPlan(string resource
143143
return createdWHP;
144144
}
145145

146-
public AzureOperationResponse RemoveWebHostingPlan(string resourceGroupName, string whpName)
146+
public AzureOperationResponse RemoveAppServicePlan(string resourceGroupName, string whpName)
147147
{
148148
var response = WrappedWebsitesClient.WebHostingPlans.Delete(resourceGroupName, whpName);
149-
//proper return type need to be discussed
150149
return response;
151150
}
152151

153-
public WebHostingPlanGetResponse GetWebHostingPlan(string resourceGroupName, string whpName)
152+
public WebHostingPlanGetResponse GetAppServicePlan(string resourceGroupName, string whpName)
154153
{
155154
var response = WrappedWebsitesClient.WebHostingPlans.Get(resourceGroupName, whpName);
156-
//proper return type need to be discussed
157155
return response;
158156
}
159157

160-
public WebHostingPlanListResponse ListWebHostingPlan(string resourceGroupName)
158+
public WebHostingPlanListResponse ListAppServicePlan(string resourceGroupName)
161159
{
162160
var response = WrappedWebsitesClient.WebHostingPlans.List(resourceGroupName);
163-
//proper return type need to be discussed
164161
return response;
165162
}
166163

0 commit comments

Comments
 (0)