Skip to content

Commit 3400374

Browse files
Merge pull request #6239 from sergey-shandar/sergey-websites3
Websites: Websites.Strategies are replaced by Common.Strategies library.
2 parents d63454a + 22e241a commit 3400374

File tree

26 files changed

+1732
-388
lines changed

26 files changed

+1732
-388
lines changed

src/ResourceManager/Common/Commands.Common.Strategies.UnitTest/AsyncCmdletExtensionsTest.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public string Location
3737
public async Task<ResourceConfig<RG>> CreateConfigAsync()
3838
=> new ResourceConfig<RG>(
3939
new ResourceStrategy<RG>(
40-
null,
40+
null,
4141
async (c, p) => new RG(),
4242
null,
4343
null,
@@ -51,7 +51,7 @@ public async Task<ResourceConfig<RG>> CreateConfigAsync()
5151

5252
class AsyncCmdlet : IAsyncCmdlet
5353
{
54-
public CancellationToken CancellationToken { get; }
54+
public CancellationToken CancellationToken { get; }
5555
= new CancellationToken();
5656

5757
public IEnumerable<KeyValuePair<string, object>> Parameters
@@ -89,6 +89,11 @@ public void WriteVerbose(string message)
8989
{
9090
Assert.Equal("Str = \"str\"", message);
9191
}
92+
93+
public void WriteWarning(string message)
94+
{
95+
throw new NotImplementedException();
96+
}
9297
}
9398

9499
[Fact]
@@ -102,4 +107,4 @@ public async Task TestVerboseStream()
102107
await client.RunAsync("subscriptionId", parameters, asyncCmdlet);
103108
}
104109
}
105-
}
110+
}

src/ResourceManager/Common/Commands.Common.Strategies/AsyncCmdletExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ public AsyncCmdlet(ICmdlet cmdlet)
191191
public void WriteVerbose(string message)
192192
=> Scheduler.BeginInvoke(() => Cmdlet.WriteVerbose(message));
193193

194+
public void WriteWarning(string message)
195+
=> Scheduler.BeginInvoke(() => Cmdlet.WriteWarning(message));
196+
194197
public Task<bool> ShouldProcessAsync(string target, string action)
195198
=> Scheduler.Invoke(() => Cmdlet.ShouldProcess(target, action));
196199

@@ -199,8 +202,6 @@ public void WriteObject(object value)
199202

200203
public void ReportTaskProgress(ITaskProgress taskProgress)
201204
=> Scheduler.BeginInvoke(() => TaskProgressList.Add(taskProgress));
202-
203-
204205
}
205206
}
206207
}

src/ResourceManager/Common/Commands.Common.Strategies/Commands.Common.Strategies.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Microsoft.Azure.Commands.Common.Strategies</RootNamespace>
11-
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies.3</AssemblyName>
11+
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies.4</AssemblyName>
1212
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
</PropertyGroup>

src/ResourceManager/Common/Commands.Common.Strategies/Common.Strategies.Netcore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<PropertyGroup>
66
<TargetFramework>netcoreapp2.0</TargetFramework>
7-
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies</AssemblyName>
7+
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies.4</AssemblyName>
88
<RootNamespace>Microsoft.Azure.Commands.Common.Strategies</RootNamespace>
99
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1010
</PropertyGroup>

src/ResourceManager/Common/Commands.Common.Strategies/IAsyncCmdlet.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public interface IAsyncCmdlet
2929
IEnumerable<KeyValuePair<string, object>> Parameters { get; }
3030

3131
/// <summary>
32+
/// Log additional information.
3233
/// Thread-safe `WriteVerbose` function.
3334
/// </summary>
34-
/// <param name="message"></param>
35+
/// <param name="message">The additional information to log</param>
3536
void WriteVerbose(string message);
3637

3738
/// <summary>
@@ -40,11 +41,17 @@ public interface IAsyncCmdlet
4041
Task<bool> ShouldProcessAsync(string target, string action);
4142

4243
/// <summary>
43-
/// Thread-safe `WriteVerbose` function.
44+
/// Thread-safe `WriteObject` function.
4445
/// </summary>
4546
/// <param name="value"></param>
4647
void WriteObject(object value);
4748

49+
/// <summary>
50+
/// Thread-safe `WriteWarning` function.
51+
/// </summary>
52+
/// <param name="message"></param>
53+
void WriteWarning(string message);
54+
4855
/// <summary>
4956
/// Report task progress. The function is used to report current task and cmdlet progress.
5057
/// </summary>
@@ -61,4 +68,4 @@ public interface IAsyncCmdlet
6168
/// </summary>
6269
CancellationToken CancellationToken { get; }
6370
}
64-
}
71+
}

src/ResourceManager/Common/Commands.Common.Strategies/ICmdlet.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public interface ICmdlet
4141
/// <param name="value"></param>
4242
void WriteObject(object value);
4343

44+
/// <summary>
45+
/// See also PowerShell `WriteWarning`.
46+
/// </summary>
47+
/// <param name="message"></param>
48+
void WriteWarning(string message);
49+
4450
/// <summary>
4551
/// See also PowerShell `WriteProgress`.
4652
/// </summary>
@@ -64,4 +70,4 @@ void WriteProgress(
6470
/// </summary>
6571
IEnumerable<KeyValuePair<string, object>> Parameters { get; }
6672
}
67-
}
73+
}

src/ResourceManager/Compute/AzureRM.Compute.Netcore.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RequiredModules = @(@{ModuleName = 'AzureRM.Profile.Netcore'; ModuleVersion = '0
5555

5656
# Assemblies that must be loaded prior to importing this module
5757
RequiredAssemblies = '.\AutoMapper.dll',
58-
'.\Microsoft.Azure.Commands.Common.Strategies.dll',
58+
'.\Microsoft.Azure.Commands.Common.Strategies.4.dll',
5959
'.\Microsoft.Azure.Management.Compute.dll',
6060
'.\Microsoft.Azure.Management.KeyVault.dll'
6161

src/ResourceManager/Compute/AzureRM.Compute.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ RequiredAssemblies = '.\AutoMapper.dll', '.\Microsoft.Azure.Management.Compute.d
6262
'.\Microsoft.WindowsAzure.Commands.Sync.dll',
6363
'.\Microsoft.WindowsAzure.Commands.Tools.Vhd.dll',
6464
'.\Microsoft.WindowsAzure.Storage.dll', '.\System.Spatial.dll',
65-
'.\Microsoft.Azure.Commands.Common.Strategies.3.dll'
65+
'.\Microsoft.Azure.Commands.Common.Strategies.4.dll'
6666

6767
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
6868
# ScriptsToProcess = @()

src/ResourceManager/Compute/Commands.Compute/Strategies/AsyncCmdletExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public void WriteProgress(
8484
CurrentOperation = currentOperation,
8585
PercentComplete = percentComplete,
8686
});
87+
88+
public void WriteWarning(string message)
89+
=> _Cmdlet.WriteWarning(message);
8790
}
8891
}
8992
}

src/ResourceManager/Websites/AzureRM.Websites.Netcore.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ PowerShellVersion = '5.1'
5454
RequiredModules = @(@{ModuleName = 'AzureRM.Profile.Netcore'; ModuleVersion = '0.11.0'; })
5555

5656
# Assemblies that must be loaded prior to importing this module
57-
RequiredAssemblies = '.\Microsoft.Azure.Management.Websites.dll', '.\Microsoft.Azure.Commands.Common.Strategies.dll'
57+
RequiredAssemblies = '.\Microsoft.Azure.Management.Websites.dll', '.\Microsoft.Azure.Commands.Common.Strategies.4.dll'
5858

5959
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
6060
# ScriptsToProcess = @()

src/ResourceManager/Websites/AzureRM.Websites.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.1.0'; }
5555

5656
# Assemblies that must be loaded prior to importing this module
5757
RequiredAssemblies = '.\Microsoft.Azure.Management.Websites.dll',
58-
'.\Microsoft.Azure.Commands.Common.Strategies.3.dll'
58+
'.\Microsoft.Azure.Commands.Common.Strategies.4.dll'
5959

6060
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
6161
# ScriptsToProcess = @()

src/ResourceManager/Websites/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* `New-AzureRMWebApp` is updated to use common algorithms from the Strategy library.
2122

2223
## Version 5.0.1
2324
* Set minimum dependency of module to PowerShell 5.0

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@
259259
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebApp.json">
260260
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
261261
</None>
262+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebAppSimple.json">
263+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
264+
</None>
262265
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestRemoveWebApp.json">
263266
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
264267
</None>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public void TestCreateNewAppOnAse()
4444
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppOnAse");
4545
}
4646

47+
[Fact]
48+
[Trait(Category.AcceptanceType, Category.CheckIn)]
49+
public void TestCreateNewWebAppSimple()
50+
{
51+
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppSimple");
52+
}
53+
4754
[Fact(Skip = "Needs investigation. Fails running playback")]
4855
[Trait(Category.AcceptanceType, Category.CheckIn)]
4956
public void TestGetWebApp()

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,4 +768,23 @@ function Test-WebAppPublishingProfile
768768
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $planName -Force
769769
Remove-AzureRmResourceGroup -Name $rgname -Force
770770
}
771+
}
772+
773+
<#
774+
.SYNOPSIS
775+
Tests creating a web app with a simple parameterset.
776+
#>
777+
function Test-CreateNewWebAppSimple
778+
{
779+
$appName = Get-WebsiteName
780+
try
781+
{
782+
$webapp = New-AzureRmWebApp -Name $appName
783+
784+
Assert-AreEqual $appName $webapp.Name
785+
}
786+
finally
787+
{
788+
Remove-AzureRmResourceGroup $appName
789+
}
771790
}

0 commit comments

Comments
 (0)