Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1092 from ogail/new

Fix test deployment
  • Loading branch information...
commit acced804c58aff1267753fea0dd62cce768e4a29 2 parents e841a66 + 2a2d8f5
@ogail ogail authored
Showing with 614 additions and 97 deletions.
  1. +9 −12 WindowsAzurePowershell/src/Local.testsettings
  2. +70 −6 WindowsAzurePowershell/src/Management.ScenarioTest/Common/CustomPowerShell/CustomerPSHostUserInterface.cs
  3. +3 −0  WindowsAzurePowershell/src/Management.ScenarioTest/Management.ScenarioTest.csproj
  4. +2 −0  WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Assert.ps1
  5. +175 −0 WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Store/Common.ps1
  6. +172 −17 WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Store/StoreTests.ps1
  7. +0 −1  WindowsAzurePowershell/src/Management.ScenarioTest/Resources/TestAzure.psd1
  8. +137 −20 WindowsAzurePowershell/src/Management.ScenarioTest/StoreTests/StoreTests.cs
  9. +1 −1  WindowsAzurePowershell/src/Management.Store/Cmdlet/GetAzureStoreAddOn.cs
  10. +1 −1  WindowsAzurePowershell/src/Management.Store/Cmdlet/NewAzureStoreAddOn.cs
  11. +1 −1  WindowsAzurePowershell/src/Management.Store/Cmdlet/RemoveAzureStoreAddOn.cs
  12. +1 −1  WindowsAzurePowershell/src/Management.Store/Cmdlet/SetAzureStoreAddOn.cs
  13. +7 −4 WindowsAzurePowershell/src/Management.Store/Model/MarketplaceClient.cs
  14. +29 −18 WindowsAzurePowershell/src/Management.Store/Model/StoreClient.cs
  15. +3 −3 WindowsAzurePowershell/src/Management.Store/Model/WindowsAzureAddOn.cs
  16. +2 −0  WindowsAzurePowershell/src/Management.Store/Properties/AssemblyInfo.cs
  17. +0 −1  WindowsAzurePowershell/src/Management/Azure.psd1
  18. +1 −11 WindowsAzurePowershell/src/Scenario.testsettings
View
21 WindowsAzurePowershell/src/Local.testsettings
@@ -2,24 +2,21 @@
<TestSettings name="Local" id="cdbdc350-d4c9-4e43-a4f9-37455108ceaa" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a local test run.</Description>
<Deployment>
- <DeploymentItem filename="Management.WebSites\Microsoft.WindowsAzure.Management.WebSites.format.ps1xml" />
- <DeploymentItem filename="Management.Test\Resources\" />
+ <DeploymentItem filename="..\..\Package\Debug" />
+ <DeploymentItem filename="Management.SqlDatabase.Test\Resources\" />
+ <DeploymentItem filename="Management.CloudService.Test\Resources\" />
<DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\dynamic_50_child02.vhd" />
- <DeploymentItem filename="Management.SqlDatabase\Microsoft.WindowsAzure.Management.SqlDatabase.dll-Help.xml" />
- <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child02.vhd" />
<DeploymentItem filename="Management.ServiceManagement.Test\Resources\" />
- <DeploymentItem filename="Management.CloudService\Resources\" />
- <DeploymentItem filename="Management.ServiceBus\Microsoft.WindowsAzure.Management.ServiceBus.format.ps1xml" />
+ <DeploymentItem filename="Management.Test\Resources\" />
+ <DeploymentItem filename="Management.ServiceBus.Test\Resources\" />
<DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\dynamic_50_child01.vhd" />
- <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child01.vhd" />
- <DeploymentItem filename="Management.ScenarioTest\Resources\" />
+ <DeploymentItem filename="Management.CloudService\Resources\" />
<DeploymentItem filename="Management.SqlDatabase.Test\TestScripts\" />
- <DeploymentItem filename="Management.ServiceBus.Test\Resources\" />
- <DeploymentItem filename="Management.SqlDatabase\Microsoft.WindowsAzure.Management.SqlDatabase.Types.ps1xml" />
+ <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child02.vhd" />
<DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50.vhd" />
<DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\dynamic_50.vhd" />
- <DeploymentItem filename="Management.CloudService.Test\Resources\" />
- <DeploymentItem filename="Management.SqlDatabase.Test\Resources\" />
+ <DeploymentItem filename="Management.ScenarioTest\Resources\" />
+ <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\fixed_50_child01.vhd" />
</Deployment>
<Execution>
<TestTypeSpecific>
View
76 WindowsAzurePowershell/src/Management.ScenarioTest/Common/CustomPowerShell/CustomerPSHostUserInterface.cs
@@ -19,6 +19,8 @@ namespace Microsoft.WindowsAzure.Management.ScenarioTest.Common.CustomPowerShell
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Host;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Microsoft.WindowsAzure.Management.Store.Model;
class CustomerPSHostUserInterface : PSHostUserInterface
{
@@ -30,7 +32,21 @@ class CustomerPSHostUserInterface : PSHostUserInterface
public List<ProgressRecord> ProgressStream { get; private set; }
- public int PromptChoice { get; set; }
+ public int Yes { get; set; }
+
+ public int No { get; set; }
+
+ public List<int> PromptChoices { get; set; }
+
+ public List<int> ExpectedDefaultChoices { get; set; }
+
+ public List<string> ExpectedPromptMessages { get; set; }
+
+ public List<string> ExpectedPromptCaptions { get; set; }
+
+ public PromptAnswer DefaultAnswer { get; set; }
+
+ private int promptCounter;
public CustomerPSHostUserInterface()
{
@@ -42,23 +58,64 @@ public CustomerPSHostUserInterface()
ProgressStream = new List<ProgressRecord>();
- PromptChoice = int.MaxValue;
+ PromptChoices = new List<int>();
+
+ ExpectedPromptMessages = new List<string>();
+
+ ExpectedPromptCaptions = new List<string>();
+
+ ExpectedDefaultChoices = new List<int>();
+
+ promptCounter = 0;
+
+ DefaultAnswer = PromptAnswer.Yes;
+
+ Yes = PowerShellCustomConfirmation.Yes;
+
+ No = PowerShellCustomConfirmation.No;
}
- public override Dictionary<string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
+ public override Dictionary<string, PSObject> Prompt(string caption, string message, Collection<FieldDescription> descriptions)
{
throw new NotImplementedException();
}
public override int PromptForChoice(string caption, string message, Collection<ChoiceDescription> choices, int defaultChoice)
{
- if (PromptChoice != int.MaxValue)
+ Assert.AreEqual<int>(
+ ExpectedPromptMessages.Count,
+ ExpectedPromptCaptions.Count,
+ "The expected captions and expected messages lists must has equal length");
+
+ Assert.AreEqual<int>(
+ ExpectedPromptCaptions.Count,
+ ExpectedDefaultChoices.Count,
+ "The expected captions and expected default choices lists must has equal length");
+
+ if (promptCounter < ExpectedPromptCaptions.Count)
{
- return PromptChoice;
+ Assert.AreEqual<string>(ExpectedPromptCaptions[promptCounter], caption);
+ Assert.AreEqual<string>(ExpectedPromptMessages[promptCounter], message);
+ Assert.AreEqual<int>(ExpectedDefaultChoices[promptCounter], defaultChoice);
+ }
+
+ if (promptCounter < PromptChoices.Count)
+ {
+ return PromptChoices[promptCounter++];
}
else
{
- return defaultChoice;
+ switch (DefaultAnswer)
+ {
+ case PromptAnswer.DefaultChoice:
+ return defaultChoice;
+ case PromptAnswer.Yes:
+ return Yes;
+ case PromptAnswer.No:
+ return No;
+ default:
+ throw new Exception();
+ }
}
}
@@ -127,4 +184,11 @@ public override void WriteWarningLine(string message)
WarningStream.Add(message);
}
}
+
+ public enum PromptAnswer
+ {
+ DefaultChoice,
+ Yes,
+ No
+ }
}
View
3  WindowsAzurePowershell/src/Management.ScenarioTest/Management.ScenarioTest.csproj
@@ -171,6 +171,9 @@
<Resource Include="Resources\Store\StoreTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
+ <Resource Include="Resources\Store\Common.ps1">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Resource>
<None Include="Resources\tipsf001.publishsettings" />
<None Include="Resources\tipsf002.publishsettings" />
<None Include="Resources\tipsf003.publishsettings" />
View
2  WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Assert.ps1
@@ -47,6 +47,8 @@ function Assert-Throws
return $true;
}
}
+
+ throw "No exception occured";
}
###################
View
175 WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Store/Common.ps1
@@ -0,0 +1,175 @@
+# ----------------------------------------------------------------------------------
+#
+# Copyright Microsoft Corporation
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ----------------------------------------------------------------------------------
+
+$createdAddOns = @()
+$availableAddOnsInUS = $null
+
+<#
+.SYNOPSIS
+Gets all available add-ons in US.
+#>
+function Get-AvailableAddOn
+{
+ if (!$availableAddOnsInUS)
+ {
+ $availableAddOnsInUS = Get-AzureStoreAddOn -ListAvailable US
+ }
+
+ return $availableAddOnsInUS
+}
+
+<#
+.SYNOPSIS
+Gets default location from the available list of add-on locations.
+
+.PARAMETER name
+The add-on id.
+#>
+function Get-DefaultAddOnLocation
+{
+ param([string] $addonId)
+
+ $addon = Get-AvailableAddOn | Where { $_.AddOn -eq $addonId }
+
+ return $addon.Locations[0]
+}
+
+<#
+.SYNOPSIS
+Gets a random object for an available add-on and free plan.
+
+#>
+function Get-RandomFreeAddOn
+{
+ $addons = Get-AvailableAddOn
+ $freeAddOns = @()
+ foreach ($addon in $addons)
+ {
+ $freePlan = $addon.Plans | Where { $_.Price -eq 0 }
+ if ($freePlan)
+ {
+ $freeAddOn = @{}
+ $freeAddOn.AddOn = $addon.AddOn
+ $freeAddOn.Plan = $freePlan
+ $freeAddOns += $freeAddOn
+ }
+ }
+ $index = Get-Random -Minimum 0 -Maximum $freeAddOns.Count
+
+ return $freeAddOns[$index]
+}
+
+<#
+.SYNOPSIS
+Gets valid and available add-on name.
+#>
+function Get-AddOnName
+{
+ do
+ {
+ $name = "OneSDK" + (Get-Random).ToString()
+ $addons = Get-AzureStoreAddOn $name
+ $used = ($addons.Count -ne 0)
+ } while ($used)
+
+ return $name
+}
+
+<#
+.SYNOPSIS
+Clears the all created resources while doing the test.
+#>
+function AddOn-TestCleanup
+{
+ foreach ($name in $global:createdAddOns)
+ {
+ try { Remove-AzureStoreAddOn $name }
+ catch { <# proceed #> }
+ }
+
+ $global:createdAddOns = @()
+}
+
+<#
+.SYNOPSIS
+Creates random add-ons with the count specified.
+
+.PARAMETER count
+The number of add-ons to create.
+#>
+function New-RandomAddOn
+{
+ param([int] $count)
+
+ if (!$count) { $count = 1 }
+
+ 1..$count | % {
+ $name = Get-AddOnName;
+ $addon = Get-RandomFreeAddOn
+ New-AzureStoreAddOn $name $addon.AddOn $addon.Plan $(Get-DefaultAddOnLocation $addon.AddOn)
+ $global:createdAddOns += $name;
+ }
+}
+
+<#
+.SYNOPSIS
+Gets free add-on from the predefined add-on list.
+#>
+function Get-FreeAddOn
+{
+ $addons = Get-AvailableAddOn
+ $freeAddOns = @()
+ foreach ($addonId in $global:freeAddOnIds)
+ #foreach ($addonId in $freeAddOnIds)
+ {
+ $addon = $addons | Where { $_.AddOn -eq $addonId }
+ Write-Debug "Addon Id: "
+ Write-Debug $addonId
+ $freePlan = $addon.Plans | Where { $_.Price -eq 0 }
+ Write-Debug "Free plan: "
+ Write-Debug $freePlan.PlanIdentifier
+ if ($freePlan)
+ {
+ Write-Debug "Geet hena"
+ $freeAddOn = @{}
+ $freeAddOn.AddOn = $addon.AddOn
+ $freeAddOn.Plan = $freePlan.PlanIdentifier
+ $freeAddOns += $freeAddOn
+ }
+ }
+ $index = Get-Random -Minimum 0 -Maximum $freeAddOns.Count
+
+ return $freeAddOns[$index]
+}
+
+<#
+.SYNOPSIS
+Creates add-ons with the count specified.
+
+.PARAMETER count
+The number of add-ons to create.
+#>
+function New-AddOn
+{
+ param([int] $count)
+
+ if (!$count) { $count = 1 }
+
+ 1..$count | % {
+ $name = Get-AddOnName;
+ $addon = Get-FreeAddOn
+ New-AzureStoreAddOn $name $addon.AddOn $addon.Plan $(Get-DefaultAddOnLocation $addon.AddOn)
+ $global:createdAddOns += $name;
+ }
+}
View
189 WindowsAzurePowershell/src/Management.ScenarioTest/Resources/Store/StoreTests.ps1
@@ -29,43 +29,75 @@ function Test-WithInvalidCredentials
Assert-Throws $cloudCmdlet "Call Set-AzureSubscription and Select-AzureSubscription first."
}
+########################################################################### Get-AzureStoreAddOn -ListAvailable Scenario Tests ###########################################################################
+
<#
.SYNOPSIS
-Tests Get-AzureStoreAvailableAddOn with invalid credentials and make sure it works.
+Tests using Get-AzureStoreAddOn -ListAvailable with default country (US)
#>
-function Test-WithInvalidCredentialsWorks
+function Test-GetAzureStoreAddOnListAvailableWithDefaultCountry
{
- # Setup
- Remove-AllSubscriptions
-
# Test
- Test-GetAzureStoreAvailableAddOnWithDefaultCountry
+ $actual = Get-AzureStoreAddOn -ListAvailable
+
+ # Assert
+ Assert-True { $actual.Count -gt 0 }
+ $actual | % { Assert-NotNull $_.Provider; Assert-NotNull $_.AddOn; Assert-NotNull $_.Plans Assert-NotNull $_.Locations }
}
-########################################################################### Get-AzureStoreAvailableAddOn Scenario Tests ###########################################################################
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn -ListAvailable with specified country that will not return any addons.
+#>
+function Test-GetAzureStoreAddOnListAvailableWithNoAddOns
+{
+ # Test
+ $actual = Get-AzureStoreAddOn -ListAvailable "E1"
+
+ # Assert
+ Assert-True { $actual.Count -eq 0 }
+}
<#
.SYNOPSIS
-Tests using Get-AzureStoreAvailableAddOn with default country (US)
+Tests using Get-AzureStoreAddOn -ListAvailable with specified country that will return addons.
#>
-function Test-GetAzureStoreAvailableAddOnWithDefaultCountry
+function Test-GetAzureStoreAddOnListAvailableWithCountry
{
# Test
- $actual = Get-AzureStoreAvailableAddOn
+ $actual = Get-AzureStoreAddOn -ListAvailable "CH"
# Assert
Assert-True { $actual.Count -gt 0 }
- $actual | % { Assert-NotNull $_.Provider; Assert-NotNull $_.AddOn; Assert-NotNull $_.Plans }
}
<#
.SYNOPSIS
-Tests using Get-AzureStoreAvailableAddOn with specified country that will not return any addons.
+Tests using Get-AzureStoreAddOn -ListAvailable with invalid country name.
#>
-function Test-GetAzureStoreAvailableAddOnWithNoAddOns
+function Test-GetAzureStoreAddOnListAvailableWithInvalidCountryName
{
# Test
- $actual = Get-AzureStoreAvailableAddOn "E1"
+ Assert-Throws { Get-AzureStoreAddOn -ListAvailable "UnitedStates" } "Cannot validate argument on parameter 'Country'. The country name is invalid, please use a valid two character country code, as described in ISO 3166-1 alpha-2."
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with empty add-ons.
+#>
+function Test-TestGetAzureStoreAddOnWithNoAddOns
+{
+ # Setup
+ $current = Get-AzureStoreAddOn
+
+ if ($current.Count -eq 0)
+ {
+ Write-Warning "The test can't run because the account is not setup correctly (add-on count should be 0)";
+ exit;
+ }
+
+ # Test
+ $actual = Get-AzureStoreAddOn
# Assert
Assert-True { $actual.Count -eq 0 }
@@ -73,10 +105,133 @@ function Test-GetAzureStoreAvailableAddOnWithNoAddOns
<#
.SYNOPSIS
-Tests using Get-AzureStoreAvailableAddOn with invalid country name.
+Tests using Get-AzureStoreAddOn with one add-on.
+#>
+function Test-TestGetAzureStoreAddOnWithOneAddOn
+{
+ # Setup
+ $current = Get-AzureStoreAddOn
+
+ if ($current.Count -eq 0)
+ {
+ Write-Warning "The test can't run because the account is not setup correctly (add-on count should be 0)";
+ exit;
+ }
+ New-AddOn
+
+ # Test
+ $actual = Get-AzureStoreAddOn
+
+ # Assert
+ Assert-True { $actual.Count -eq 1 }
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with many add-ons
+#>
+function Test-GetAzureStoreAddOnWithMultipleAddOns
+{
+ # Setup
+ New-AddOn 3
+
+ # Test
+ $actual = Get-AzureStoreAddOn
+
+ # Assert
+ Assert-True { $actual.Count -gt 1 }
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with getting existing add-on
+#>
+function Test-GetAzureStoreAddOnWithExistingAddOn
+{
+ # Setup
+ New-AddOn
+ $expected = $global:createdAddOns[0]
+
+ # Test
+ $actual = Get-AzureStoreAddOn $global:createdAddOns[0]
+
+ # Assert
+ $actual = $actual[0].Name
+ Assert-AreEqual $expected $actual
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with case invesitive.
+#>
+function Test-GetAzureStoreAddOnCaseInsinsitive
+{
+ # Setup
+ New-AddOn
+ $expected = $global:createdAddOns[0]
+
+ # Test
+ $actual = Get-AzureStoreAddOn $expected.ToUpper()
+
+ # Assert
+ $actual = $actual[0].Name
+ Assert-AreEqual $expected.ToUpper() $actual.ToUpper()
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with invalid add-on name, expects to fail.
#>
-function Test-GetAzureStoreAvailableAddOnWithInvalidCountryName
+function Test-GetAzureStoreAddOnWithInvalidName
{
# Test
- Assert-Throws { Get-AzureStoreAvailableAddOn "UnitedStates" } "Cannot validate argument on parameter 'Country'. The country name is invalid, please use a valid two character country code, as described in ISO 3166-1 alpha-2."
+ Assert-Throws { Get-AzureStoreAddOn "Invalid Name" } "The provided add-on name 'Invalid Name' is invalid"
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with valid and non-existing add-on.
+#>
+function Test-GetAzureStoreAddOnValidNonExisting
+{
+ # Test
+ $actual = Get-AzureStoreAddOn "NonExistingAddOn"
+
+ # Assert
+ Assert-AreEqual 0 $actual.Count
+}
+
+<#
+.SYNOPSIS
+Tests using Get-AzureStoreAddOn with App Service
+#>
+function Test-GetAzureStoreAddOnWithAppService
+{
+ # Setup
+ New-AddOn
+
+ # Test
+ $actual = Get-AzureStoreAddOn
+
+ # Assert
+ $addon = $actual[0]
+ Assert-AreEqual "App Service" $addon.Type
+}
+
+<#
+.SYNOPSIS
+Tests the piping between Get-AzureAddOn and Remove-AzureAddOn
+#>
+function Test-GetAzureStoreAddOnPipedToRemoveAzureAddOn
+{
+ # Setup
+ New-AddOn
+ $name = $global:createdAddOns[0]
+
+ # Test
+ Get-AzureStoreAddOn $name | Remove-AzureStoreAddOn
+
+ # Assert
+ $actual = Get-AzureStoreAddOn $name
+ Assert-AreEqual 0 $actual.Count
}
View
1  WindowsAzurePowershell/src/Management.ScenarioTest/Resources/TestAzure.psd1
@@ -58,7 +58,6 @@ ScriptsToProcess = @()
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = '.\Microsoft.WindowsAzure.Management.CloudService.dll',
- '.\Microsoft.WindowsAzure.Management.Service.dll',
'.\Microsoft.WindowsAzure.Management.Websites.dll',
'.\Microsoft.WindowsAzure.Management.ServiceManagement.dll',
'.\Microsoft.WindowsAzure.Management.ServiceBus.dll',
View
157 WindowsAzurePowershell/src/Management.ScenarioTest/StoreTests/StoreTests.cs
@@ -14,12 +14,12 @@
namespace Microsoft.WindowsAzure.Management.ScenarioTest.StoreTests
{
- using System.Management.Automation;
+ using System.Collections.Generic;
using System.Management.Automation.Runspaces;
using Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure.Management.ScenarioTest.Common.CustomPowerShell;
- using Microsoft.WindowsAzure.Management.Store.Model;
+ using Microsoft.WindowsAzure.Management.Store.Properties;
[TestClass]
public class StoreTests : WindowsAzurePowerShellTest
@@ -31,7 +31,9 @@ public class StoreTests : WindowsAzurePowerShellTest
private CustomHost customHost;
public StoreTests()
- : base("Store\\StoreTests.ps1")
+ : base(
+ "Store\\Common.ps1",
+ "Store\\StoreTests.ps1")
{
customHost = new CustomHost();
}
@@ -41,61 +43,176 @@ public override void TestSetup()
{
base.TestSetup();
customHost = new CustomHost();
+ powershell.ImportCredentials(StoreCredentialFile);
+ powershell.AddScript(string.Format("Set-AzureSubscription -Default {0}", StoreSubscriptionName));
+ }
+
+ private void PromptSetup()
+ {
+ PromptSetup(
+ new List<int>(),
+ new List<int>(),
+ new List<string>(),
+ new List<string>(),
+ PromptAnswer.Yes);
}
- private void PromptSetup(int choice)
+ private void PromptSetup(
+ List<int> expectedDefaultChoices,
+ List<int> promptChoices,
+ List<string> expectedPromptMessages,
+ List<string> expectedPromptCaptions,
+ PromptAnswer defaultAnswer)
{
- customHost.CustomUI.PromptChoice = choice;
+ customHost.CustomUI.PromptChoices = promptChoices;
+ customHost.CustomUI.ExpectedDefaultChoices = expectedDefaultChoices;
+ customHost.CustomUI.ExpectedPromptMessages = expectedPromptMessages;
+ customHost.CustomUI.ExpectedPromptCaptions = expectedPromptCaptions;
+ customHost.CustomUI.DefaultAnswer = defaultAnswer;
powershell.Runspace = RunspaceFactory.CreateRunspace(customHost);
powershell.Runspace.Open();
- powershell.ImportCredentials(StoreCredentialFile);
- powershell.AddScript(string.Format("Set-AzureSubscription -Default {0}", StoreSubscriptionName));
+ powershell.SetVariable(
+ "freeAddOnIds",
+ new string[] { "activecloudmonitoring", "sendgrid_azure" });
}
- #region Get-AzureStoreAvailableAddOn Scenario Tests
+ #region Get-AzureStoreAddOn Scenario Tests
[TestMethod]
[TestCategory(Category.All)]
[TestCategory(Category.Store)]
- public void TestWithInvalidCredentialsWorks()
+ public void TestGetAzureStoreAddOnListAvailableWithInvalidCredentials()
{
- RunPowerShellTest("Test-WithInvalidCredentialsWorks");
+ RunPowerShellTest("Test-WithInvalidCredentials { Get-AzureStoreAddOn -ListAvailable }");
}
[TestMethod]
[TestCategory(Category.All)]
[TestCategory(Category.Store)]
- public void TestGetAzureStoreAvailableAddOnWithDefaultCountry()
+ public void TestGetAzureStoreAddOnListAvailableWithDefaultCountry()
{
- RunPowerShellTest("Test-GetAzureStoreAvailableAddOnWithDefaultCountry");
+ RunPowerShellTest("Test-GetAzureStoreAddOnListAvailableWithDefaultCountry");
}
[TestMethod]
[TestCategory(Category.All)]
[TestCategory(Category.Store)]
- public void TestGetAzureStoreAvailableAddOnWithNoAddOns()
+ public void TestGetAzureStoreAddOnListAvailableWithNoAddOns()
{
- RunPowerShellTest("Test-GetAzureStoreAvailableAddOnWithNoAddOns");
+ RunPowerShellTest("Test-GetAzureStoreAddOnListAvailableWithNoAddOns");
}
[TestMethod]
[TestCategory(Category.All)]
[TestCategory(Category.Store)]
- public void TestGetAzureStoreAvailableAddOnWithInvalidCountryName()
+ public void TestGetAzureStoreAddOnListAvailableWithCountry()
{
- RunPowerShellTest("Test-GetAzureStoreAvailableAddOnWithInvalidCountryName");
+ RunPowerShellTest("Test-GetAzureStoreAddOnListAvailableWithCountry");
}
- #endregion
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnListAvailableWithInvalidCountryName()
+ {
+ RunPowerShellTest("Test-GetAzureStoreAddOnListAvailableWithInvalidCountryName");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithInvalidCredentials()
+ {
+ RunPowerShellTest("Test-WithInvalidCredentials { Get-AzureStoreAddOn Name }");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithNoAddOns()
+ {
+ RunPowerShellTest("Test-GetAzureStoreAddOnEmpty");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithOneAddOn()
+ {
+ PromptSetup();
+ RunPowerShellTest(
+ "Test-GetAzureStoreAddOnWithOneAddOn",
+ "AddOn-TestCleanup");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithMultipleAddOns()
+ {
+ PromptSetup();
+ RunPowerShellTest(
+ "AddOn-TestCleanup",
+ "Test-GetAzureStoreAddOnWithMultipleAddOns",
+ "AddOn-TestCleanup");
+ }
- #region Get-AzureStoreAddOn Scneario Tests
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithExistingAddOn()
+ {
+ PromptSetup();
+ RunPowerShellTest(
+ "Test-GetAzureStoreAddOnWithExistingAddOn",
+ "AddOn-TestCleanup");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnCaseInsinsitive()
+ {
+ PromptSetup();
+ RunPowerShellTest(
+ "Test-GetAzureStoreAddOnCaseInsinsitive",
+ "AddOn-TestCleanup");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithInvalidName()
+ {
+ RunPowerShellTest("Test-GetAzureStoreAddOnWithInvalidName");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnValidNonExisting()
+ {
+ RunPowerShellTest("Test-GetAzureStoreAddOnValidNonExisting");
+ }
+
+ [TestMethod]
+ [TestCategory(Category.All)]
+ [TestCategory(Category.Store)]
+ public void TestGetAzureStoreAddOnWithAppService()
+ {
+ PromptSetup();
+ RunPowerShellTest("Test-GetAzureStoreAddOnWithAppService");
+ }
[TestMethod]
[TestCategory(Category.All)]
[TestCategory(Category.Store)]
- public void TestNewAzureStoreAddOnWithInvalidCredentials()
+ public void TestGetAzureStoreAddOnPipedToRemoveAzureAddOn()
{
- RunPowerShellTest("Test-WithInvalidCredentials { New-AzureStoreAddOn Name AddOnPlan Location}");
+ PromptSetup();
+ RunPowerShellTest(
+ "Test-GetAzureStoreAddOnPipedToRemoveAzureAddOn",
+ "AddOn-TestCleanup");
}
#endregion
View
2  WindowsAzurePowershell/src/Management.Store/Cmdlet/GetAzureStoreAddOn.cs
@@ -27,7 +27,7 @@ namespace Microsoft.WindowsAzure.Management.Store.Cmdlet
/// Gets all available Windows Azure add-ons from Marketplace and gets user purchased add-ons.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureStoreAddOn"), OutputType(typeof(List<WindowsAzureAddOn>), typeof(List<WindowsAzureOffer>))]
- public class GetAzureStoreAddOnCommand : CloudBaseCmdlet<IServiceManagement>
+ public class GetAzureStoreAddOnCommand : ServiceManagementBaseCmdlet
{
const string ListAvailableParameterSet = "ListAvailable";
View
2  WindowsAzurePowershell/src/Management.Store/Cmdlet/NewAzureStoreAddOn.cs
@@ -26,7 +26,7 @@ namespace Microsoft.WindowsAzure.Management.Store.Cmdlet
/// Purchase a new Add-On from Windows Azure Store.
/// </summary>
[Cmdlet(VerbsCommon.New, "AzureStoreAddOn"), OutputType(typeof(bool))]
- public class NewAzureStoreAddOnCommand : CloudBaseCmdlet<IServiceManagement>
+ public class NewAzureStoreAddOnCommand : ServiceManagementBaseCmdlet
{
public StoreClient StoreClient { get; set; }
View
2  WindowsAzurePowershell/src/Management.Store/Cmdlet/RemoveAzureStoreAddOn.cs
@@ -26,7 +26,7 @@ namespace Microsoft.WindowsAzure.Management.Store.Cmdlet
/// Removes all purchased Add-Ons or specific Add-On
/// </summary>
[Cmdlet(VerbsCommon.Remove, "AzureStoreAddOn"), OutputType(typeof(List<PSObject>))]
- public class RemoveAzureStoreAddOnCommand : CloudBaseCmdlet<IServiceManagement>
+ public class RemoveAzureStoreAddOnCommand : ServiceManagementBaseCmdlet
{
public StoreClient StoreClient { get; set; }
View
2  WindowsAzurePowershell/src/Management.Store/Cmdlet/SetAzureStoreAddOn.cs
@@ -25,7 +25,7 @@ namespace Microsoft.WindowsAzure.Management.Store.Cmdlet
/// Purchase a new Add-On from Windows Azure Store.
/// </summary>
[Cmdlet(VerbsCommon.Set, "AzureStoreAddOn"), OutputType(typeof(bool))]
- public class SetAzureStoreAddOnCommand : CloudBaseCmdlet<IServiceManagement>
+ public class SetAzureStoreAddOnCommand : ServiceManagementBaseCmdlet
{
public StoreClient StoreClient { get; set; }
View
11 WindowsAzurePowershell/src/Management.Store/Model/MarketplaceClient.cs
@@ -75,10 +75,13 @@ public virtual List<WindowsAzureOffer> GetAvailableWindowsAzureOffers(string cou
IEnumerable<Plan> validPlans = offer.Plans.Where<Plan>(p => p.CountryCode == countryCode);
IEnumerable<string> offerLocations = offer.Categories.Select<Category, string>(c => c.Name)
.Intersect<string>(SubscriptionLocations);
- result.Add(new WindowsAzureOffer(
- offer,
- validPlans,
- offerLocations.Count() == 0 ? SubscriptionLocations : offerLocations));
+ if (validPlans.Count() > 0)
+ {
+ result.Add(new WindowsAzureOffer(
+ offer,
+ validPlans,
+ offerLocations.Count() == 0 ? SubscriptionLocations : offerLocations));
+ }
}
nextOfferLink = offerResponse.GetContinuation();
View
47 WindowsAzurePowershell/src/Management.Store/Model/StoreClient.cs
@@ -36,8 +36,6 @@ public class StoreClient
private const string DataMarketResourceProviderNamespace = "DataMarket";
- private const string DataService = "Data";
-
private const string AppService = "AzureDevService";
private const string StoreServicePrefix = "Azure-Stores";
@@ -142,7 +140,7 @@ private void WaitForOperation(string operationId)
private bool IsDataService(string type)
{
- return type.Equals(DataService, StringComparison.OrdinalIgnoreCase);
+ return type.Equals(WindowsAzureAddOn.DataType, StringComparison.OrdinalIgnoreCase);
}
public MarketplaceClient MarketplaceClient { get; set; }
@@ -227,14 +225,18 @@ public virtual void RemoveAddOn(string name)
throw new Exception(string.Format(Resources.AddOnNotFound, name));
}
- WindowsAzureAddOn addOn = addOns[0];
+ WindowsAzureAddOn addon = addOns[0];
+ string type;
+ string cloudService;
+ string addonId;
+ addonId = GetResourceInformation(addon.AddOn, addon.Location, out type, out cloudService);
storeChannel.DeleteResource(
subscriptionId,
- addOn.CloudService,
- addOn.Type,
- addOn.AddOn,
- addOn.Name
+ cloudService,
+ type,
+ addonId,
+ name
);
WaitForOperation(headersInspector.ResponseHeaders[ServiceManagementConstants.OperationTrackingIdHeader]);
@@ -247,11 +249,10 @@ public virtual void RemoveAddOn(string name)
string location,
string promotionCode)
{
- Offer offer = MarketplaceClient.GetOffer(addon);
- string type = offer.OfferType;
- string provider = offer.ProviderIdentifier;
- string cloudService = CreateCloudServiceIfNotExists(location);
- type = IsDataService(type) ? DataMarketResourceProviderNamespace : provider;
+ string type;
+ string cloudService;
+ addon = GetResourceInformation(addon, location, out type, out cloudService);
+
Resource resource = new Resource()
{
Plan = plan,
@@ -259,11 +260,6 @@ public virtual void RemoveAddOn(string name)
PromotionCode = promotionCode
};
- if (type.Equals(DataMarketResourceProviderNamespace, StringComparison.OrdinalIgnoreCase))
- {
- addon = string.Format("{0}-{1}", provider, addon);
- }
-
try
{
storeChannel.CreateResource(subscriptionId, cloudService, type, addon, name, resource);
@@ -279,6 +275,21 @@ public virtual void RemoveAddOn(string name)
WaitForOperation(headersInspector.ResponseHeaders[ServiceManagementConstants.OperationTrackingIdHeader]);
}
+ private string GetResourceInformation(string addon, string location, out string type, out string cloudService)
+ {
+ Offer offer = MarketplaceClient.GetOffer(addon);
+ type = offer.OfferType;
+ string provider = offer.ProviderIdentifier;
+ cloudService = CreateCloudServiceIfNotExists(location);
+ type = IsDataService(type) ? DataMarketResourceProviderNamespace : provider;
+
+ if (type.Equals(DataMarketResourceProviderNamespace, StringComparison.OrdinalIgnoreCase))
+ {
+ addon = string.Format("{0}-{1}", provider, addon);
+ }
+ return addon;
+ }
+
/// <summary>
/// Gets confirmation message for the given operation.
/// </summary>
View
6 WindowsAzurePowershell/src/Management.Store/Model/WindowsAzureAddOn.cs
@@ -19,11 +19,11 @@ namespace Microsoft.WindowsAzure.Management.Store.Model
public class WindowsAzureAddOn
{
- const string DataSetType = "DataMarket";
+ public const string DataSetType = "DataMarket";
- const string DataType = "Data";
+ public const string DataType = "Data";
- const string AppServiceType = "App Service";
+ public const string AppServiceType = "App Service";
public string Type { get; set; }
View
2  WindowsAzurePowershell/src/Management.Store/Properties/AssemblyInfo.cs
@@ -47,7 +47,9 @@
[assembly: AssemblyFileVersion("0.6.9")]
#if SIGN
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Management.Store.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
+[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Management.ScenarioTest, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
#else
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Management.Store.Test")]
+[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Management.ScenarioTest")]
#endif
[assembly: CLSCompliant(false)]
View
1  WindowsAzurePowershell/src/Management/Azure.psd1
@@ -73,7 +73,6 @@ FormatsToProcess = @(
# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = '.\Microsoft.WindowsAzure.Management.CloudService.dll',
- '.\Microsoft.WindowsAzure.Management.Service.dll',
'.\Microsoft.WindowsAzure.Management.SqlDatabase.dll',
'.\Microsoft.WindowsAzure.Management.Websites.dll',
'.\Microsoft.WindowsAzure.Management.ServiceBus.dll',
View
12 WindowsAzurePowershell/src/Scenario.testsettings
@@ -2,17 +2,7 @@
<TestSettings name="Scenario" id="be8eaf83-f542-4927-b5a8-d3b48b22a87d" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a scenario test run.</Description>
<Deployment>
- <DeploymentItem filename="Management.ServiceBus\Microsoft.WindowsAzure.Management.ServiceBus.format.ps1xml" />
- <DeploymentItem filename="Management.ServiceBus.Test\Resources\" />
- <DeploymentItem filename="Management.WebSites\Microsoft.WindowsAzure.Management.WebSites.format.ps1xml" />
- <DeploymentItem filename="Management.WebSites\Microsoft.WindowsAzure.Management.WebSites.Types.ps1xml" />
- <DeploymentItem filename="Management.CloudService.Test\Resources\" />
- <DeploymentItem filename="Management.ServiceManagement.Test\VhdFiles\" />
- <DeploymentItem filename="Management.ServiceManagement.Test\Resources\" />
- <DeploymentItem filename="Management.CloudService\Resources\" />
- <DeploymentItem filename="Management.Test\Resources\" />
- <DeploymentItem filename="Management.ScenarioTest\Resources\" />
- <DeploymentItem filename="Management.CloudService\Microsoft.WindowsAzure.Management.CloudService.format.ps1xml" />
+ <DeploymentItem filename="..\..\Package\Debug" />
</Deployment>
<Execution>
<TestTypeSpecific>
Please sign in to comment.
Something went wrong with that request. Please try again.