Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #691 from ogail/676

Fix messaging for Get-AzureServiceProjectRoleRuntime cmdlet
  • Loading branch information...
commit ddb5bae8b24a8e13a4caed05337e364dfc1853ac 2 parents b3e06c8 + 260e60a
Abdelrahman Elogeel ogail authored
36 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/GetAzureServiceProjectRuntimesTest.cs
View
@@ -12,17 +12,32 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Microsoft.WindowsAzure.Management.CloudService.Model;
-using Microsoft.WindowsAzure.Management.CloudService.Properties;
-using Microsoft.WindowsAzure.Management.CloudService.Test.Utilities;
-
namespace Microsoft.WindowsAzure.Management.CloudService.Test.Tests.Cmdlet
{
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+ using Microsoft.WindowsAzure.Management.CloudService.Cmdlet;
+ using Microsoft.WindowsAzure.Management.CloudService.Model;
+ using Microsoft.WindowsAzure.Management.CloudService.Test.Utilities;
+
[TestClass]
public class GetAzureServiceProjectRuntimesTests : TestBase
{
private const string serviceName = "AzureService";
+
+ private FakeWriter writer;
+
+ private GetAzureServiceProjectRoleRuntimeCommand cmdlet;
+
+ [TestInitialize]
+ public void SetupTest()
+ {
+ writer = new FakeWriter();
+ cmdlet = new GetAzureServiceProjectRoleRuntimeCommand();
+ cmdlet.Writer = writer;
+ }
/// <summary>
/// Verify that the correct runtimes are returned in the correct format from a given runtime manifest
@@ -33,10 +48,15 @@ public void TestGetRuntimes()
using (FileSystemHelper files = new FileSystemHelper(this))
{
AzureService service = new AzureService(files.RootPath, serviceName, null);
- service.AddWebRole(Resources.NodeScaffolding);
string manifest = RuntimePackageHelper.GetTestManifest(files);
- CloudRuntimeCollection collection = service.GetCloudRuntimes(service.Paths, manifest);
- RuntimePackageHelper.ValidateRuntimesMatchManifest(manifest, collection);
+ CloudRuntimeCollection expected = service.GetCloudRuntimes(service.Paths, manifest);
+
+ cmdlet.GetAzureRuntimesProcess(string.Empty, Path.Combine(files.RootPath, serviceName), manifest);
+
+ List<CloudRuntimePackage> actual = writer.OutputChannel[0] as List<CloudRuntimePackage>;
+
+ Assert.AreEqual<int>(expected.Count, actual.Count);
+ Assert.IsTrue(expected.All<CloudRuntimePackage>( p => actual.Any<CloudRuntimePackage>(p2 => p2.PackageUri.Equals(p.PackageUri))));
}
}
}
31 WindowsAzurePowershell/src/Management.CloudService/Cmdlet/GetAzureServiceProjectRoleRuntime.cs
View
@@ -14,13 +14,12 @@
namespace Microsoft.WindowsAzure.Management.CloudService.Cmdlet
{
- using System;
using System.Linq;
using System.Management.Automation;
+ using System.Security.Permissions;
using Common;
- using Model;
- using Services;
using Microsoft.Samples.WindowsAzure.ServiceManagement;
+ using Model;
/// <summary>
/// Retrieve a list of role runtimes available in the cloud
@@ -38,29 +37,21 @@ public class GetAzureServiceProjectRoleRuntimeCommand : CloudCmdlet<IServiceMana
/// <param name="runtimeType">The runtime type to filter by</param>
/// <param name="rootPath">The path to the service in question</param>
/// <param name="manifest">The path to the manifest file, if null, the default cloud manifest is used (test hook)</param>
+ [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public void GetAzureRuntimesProcess(string runtimeType, string rootPath, string manifest = null)
{
AzureService service = new AzureService(rootPath, null);
CloudRuntimeCollection runtimes = service.GetCloudRuntimes(service.Paths, manifest);
- WriteObject(runtimes.Where<CloudRuntimePackage>(p => string.IsNullOrEmpty(runtimeType) ||
- p.Runtime == CloudRuntime.GetRuntimeByType(runtimeType)), true);
+ WriteOutputObject(runtimes.Where<CloudRuntimePackage>(p => string.IsNullOrEmpty(runtimeType) ||
+ p.Runtime == CloudRuntime.GetRuntimeByType(runtimeType)).ToList<CloudRuntimePackage>());
}
- /// <summary>
- /// Do work on Pipeline objects
- /// </summary>
- protected override void ProcessRecord()
+ [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
+ public override void ExecuteCmdlet()
{
- try
- {
- SkipChannelInit = true;
- base.ProcessRecord();
- this.GetAzureRuntimesProcess(Runtime, base.GetServiceRootPath());
- }
- catch (Exception ex)
- {
- SafeWriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
- }
- }
+ base.ExecuteCmdlet();
+ SkipChannelInit = true;
+ this.GetAzureRuntimesProcess(Runtime, base.GetServiceRootPath());
+ }
}
}
30 ...AzurePowershell/src/Management.CloudService/Microsoft.WindowsAzure.Management.CloudService.format.ps1xml
View
@@ -45,5 +45,35 @@
</ListEntries>
</ListControl>
</View>
+ <View>
+ <Name>Microsoft.WindowsAzure.Management.CloudService.Model.CloudRuntimePackage</Name>
+ <ViewSelectedBy>
+ <TypeName>Microsoft.WindowsAzure.Management.CloudService.Model.CloudRuntimePackage</TypeName>
+ </ViewSelectedBy>
+ <ListControl>
+ <ListEntries>
+ <ListEntry>
+ <ListItems>
+ <ListItem>
+ <Label>Runtime</Label>
+ <PropertyName>Runtime</PropertyName>
+ </ListItem>
+ <ListItem>
+ <Label>Version</Label>
+ <PropertyName>Version</PropertyName>
+ </ListItem>
+ <ListItem>
+ <Label>PackageUri</Label>
+ <PropertyName>PackageUri</PropertyName>
+ </ListItem>
+ <ListItem>
+ <Label>IsDefault</Label>
+ <PropertyName>IsDefault</PropertyName>
+ </ListItem>
+ </ListItems>
+ </ListEntry>
+ </ListEntries>
+ </ListControl>
+ </View>
</ViewDefinitions>
</Configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.