Skip to content

Commit d99847b

Browse files
authored
Merge pull request Azure#9814 from poadhika/master
Introducing PowerShell Cmdlets for the Management of HealthcareApis Service
2 parents 7467e7c + 77254e0 commit d99847b

35 files changed

+5481
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PsModuleName>HealthcareApis</PsModuleName>
5+
</PropertyGroup>
6+
7+
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
8+
9+
<PropertyGroup>
10+
<RootNamespace>Microsoft.Azure.Commands.HealthcareApis.Test</RootNamespace>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.Azure.Management.HealthcareApis" Version="1.0.1-preview" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\HealthcareApis\HealthcareApis.csproj" />
19+
</ItemGroup>
20+
21+
22+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
using Xunit;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("HealthcareApis.Test")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("HealthcareApis.Test")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4a4bc09c-0a7d-4469-8998-2a87bc95b6a7")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0")]
37+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Gets valid resource group name
18+
#>
19+
function Get-ResourceGroupName
20+
{
21+
return getAssetName
22+
}
23+
24+
<#
25+
.SYNOPSIS
26+
Gets valid resource name
27+
#>
28+
function Get-ResourceName
29+
{
30+
return getAssetName
31+
}
32+
33+
<#
34+
.SYNOPSIS
35+
Gets valid location name
36+
#>
37+
function Get-Location
38+
{
39+
return "West US"
40+
}
41+
42+
<#
43+
.SYNOPSIS
44+
Gets offerThroughput value
45+
#>
46+
function Get-OfferThroughput
47+
{
48+
return 1000
49+
}
50+
51+
<#
52+
.SYNOPSIS
53+
Gets kind value
54+
#>
55+
function Get-Kind
56+
{
57+
return "fhir-R4"
58+
}
59+
60+
<#
61+
.SYNOPSIS
62+
Cleans the created resource groups
63+
#>
64+
function Clean-ResourceGroup($rgname)
65+
{
66+
Remove-AzResourceGroup -Name $rgname -Force
67+
}
68+
69+
<#
70+
.SYNOPSIS
71+
Gets objectID value
72+
#>
73+
function Get-AccessPolicyObjectID
74+
{
75+
return "9b52f7aa-85e9-47e2-8f10-af57e63a4ae1"
76+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.ServiceManagement.Common.Models;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
18+
using Xunit;
19+
using Xunit.Abstractions;
20+
21+
namespace Microsoft.Azure.Commands.HealthcareApisService.Test.ScenarioTests
22+
{
23+
public class HealthcareApisServiceTests : RMTestBase
24+
{
25+
public XunitTracingInterceptor _logger;
26+
27+
public HealthcareApisServiceTests(ITestOutputHelper output)
28+
{
29+
_logger = new XunitTracingInterceptor(output);
30+
XunitTracingInterceptor.AddToContext(_logger);
31+
}
32+
33+
[Fact]
34+
[Trait(Category.AcceptanceType, Category.CheckIn)]
35+
public void TestAzRmHealthcareApisService()
36+
{
37+
HeathcareApisServiceController.NewInstance.RunPsTest(_logger, "Test-AzRmHealthcareApisService");
38+
}
39+
}
40+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
16+
#################################
17+
## HealthcareApis Cmdlet
18+
#################################
19+
20+
$global:resourceType = "Microsoft.HealthcareApis/services"
21+
22+
<#
23+
.SYNOPSIS
24+
Tests CRUD Operations for HealthcareApis Fhir Service.
25+
#>
26+
function Test-AzRmHealthcareApisService{
27+
# Setup
28+
$rgname = Get-ResourceGroupName
29+
$rname = Get-ResourceName
30+
$location = Get-Location
31+
$offerThroughput = Get-OfferThroughput
32+
$kind = Get-Kind
33+
$object_id = Get-AccessPolicyObjectID;
34+
35+
try
36+
{
37+
# Test
38+
# Create Resource Group
39+
New-AzResourceGroup -Name $rgname -Location $location
40+
41+
# Create App
42+
43+
$created = New-AzHealthcareApisService -Name $rname -ResourceGroupName $rgname -Location $location -Kind $kind -AccessPolicyObjectId $object_id -CosmosOfferThroughput $offerThroughput;
44+
45+
$actual = Get-AzHealthcareApisService -ResourceGroupName $rgname -Name $rname
46+
47+
# Assert
48+
Assert-AreEqual $actual.Name $rname
49+
Assert-AreEqual $actual.Properties.CosmosDbConfiguration.OfferThroughput $offerThroughput
50+
#Update using parameters
51+
$newOfferThroughput = $offerThroughput - 600
52+
$updated = Set-AzHealthcareApisService -ResourceId $actual.Id -CosmosOfferThroughput $newOfferThroughput;
53+
54+
$updatedAccount = Get-AzHealthcareApisService -ResourceGroupName $rgname -Name $rname
55+
# Assert the update
56+
Assert-AreEqual $updatedAccount.Name $rname
57+
Assert-AreEqual $updatedAccount.Properties.CosmosDbConfiguration.OfferThroughput $newOfferThroughput
58+
59+
$rname1 = $rname + "1"
60+
$created1 = New-AzHealthcareApisService -Name $rname1 -ResourceGroupName $rgname -Location $location -AccessPolicyObjectId $object_id -CosmosOfferThroughput $offerThroughput;
61+
62+
$actual1 = Get-AzHealthcareApisService -ResourceGroupName $rgname -Name $rname1
63+
64+
# Assert
65+
Assert-AreEqual $actual1.Name $rname1
66+
Assert-AreEqual $actual1.Properties.CosmosDbConfiguration.OfferThroughput $offerThroughput
67+
68+
$list = Get-AzHealthcareApisService -ResourceGroupName $rgname
69+
70+
$app1 = $list | where {$_.Name -eq $rname} | Select-Object -First 1
71+
$app2 = $list | where {$_.Name -eq $rname1} | Select-Object -First 1
72+
73+
Assert-AreEqual 2 @($list).Count
74+
Assert-AreEqual $rname $app1.Name
75+
Assert-AreEqual $rname1 $app2.Name
76+
77+
$list | Remove-AzHealthcareApisService
78+
79+
$list = Get-AzHealthcareApisService -ResourceGroupName $rgname
80+
81+
Assert-AreEqual 0 @($list).Count
82+
}
83+
finally{
84+
# Clean up
85+
Remove-AzResourceGroup -Name $rgname -Force
86+
}
87+
}

0 commit comments

Comments
 (0)