Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/MixedReality/MixedReality.Test/MixedReality.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>MixedReality</PsModuleName>
<ApplicationIcon />
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.MixedReality" Version="0.9.0-preview" />
</ItemGroup>

<ItemGroup>
<Folder Include="SessionRecords\Microsoft.Azure.Commands.MixedReality.Test.SpatialAnchorsAccountTests\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Accounts\Accounts\Accounts.csproj" />
<ProjectReference Include="..\MixedReality\MixedReality.csproj" />
</ItemGroup>

</Project>
50 changes: 50 additions & 0 deletions src/MixedReality/MixedReality.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System.Reflection;
using System.Runtime.InteropServices;
using Xunit;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.Azure.Commands.MixedRealty.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Microsoft.Azure.Commands.MixedRealty.Test")]
[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("822d5889-438f-4c18-9c06-f5db728d417d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.0.0")]
[assembly: AssemblyFileVersion("4.0.0")]
[assembly: CollectionBehavior(DisableTestParallelization = true)]
121 changes: 121 additions & 0 deletions src/MixedReality/MixedReality.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Gets valid resource group name
#>
function Get-ResourceGroupName
{
return getAssetName
}

<#
.SYNOPSIS
Gets valid resource name
#>
function Get-ResourceName
{
return getAssetName
}

<#
.SYNOPSIS
Gets the default location for a provider
#>
function Get-ProviderLocation($provider)
{
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$namespace = $provider.Split("/")[0]
if($provider.Contains("/"))
{
$type = $provider.Substring($namespace.Length + 1)
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}

if ($location -eq $null)
{
return "West US"
} else
{
return $location.Locations[0]
}
}

return "West US"
}

return "WestUS"
}

<#
.SYNOPSIS
Creates a resource group to use in tests
#>
function TestSetup-CreateResourceGroup
{
$resourceGroupName = getAssetName
$rglocation = Get-ProviderLocation "East US"
$resourceGroup = New-AzureRmResourceGroup -Name $resourceGroupName -location $rglocation -Force
return $resourceGroup
}

<#
.SYNOPSIS
Asserts if two tags are equal
#>
function Assert-Tags($tags1, $tags2)
{
if($tags1.count -ne $tags2.count)
{
throw "Tag size not equal. Tag1: $tags1.count Tag2: $tags2.count"
}

foreach($key in $tags1.Keys)
{
if($tags1[$key] -ne $tags2[$key])
{
throw "Tag content not equal. Key:$key Tags1:" + $tags1[$key] + "Tags2:" + $tags2[$key]
}
}
}

<#
.SYNOPSIS
Asserts if two compression types are equal
#>
function Assert-CompressionTypes($types1, $types2)
{
if($types1.Count -ne $types1.Count)
{
throw "Array size not equal. Types1: $types1.count Types2: $types2.count"
}

foreach($value1 in $types1)
{
$found = $false
foreach($value2 in $types2)
{
if($value1.CompareTo($value2) -eq 0)
{
$found = $true
break
}
}
if(-Not($found))
{
throw "Compression content not equal. " + $value1 + " cannot be found in second array"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.MixedReality.Test
{
public class SpatialAnchorsAccountTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public SpatialAnchorsAccountTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSpatialAnchorsAccountOperations()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SpatialAnchorsAccountOperations");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSpatialAnchorsAccountOperationsWithPiping()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SpatialAnchorsAccountOperationsWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListSpatialAnchorsAccounts()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListSpatialAnchorsAccounts");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Create Get and Delete Spatial Anchors Account
#>
function Test-SpatialAnchorsAccountOperations
{
$resourceGroup = TestSetup-CreateResourceGroup
$resourceLocation = "EastUS2"
$accountName = getAssetName

$createdAccount = New-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Location $resourceLocation
Assert-AreEqual $accountName $createdAccount.Name
Assert-AreEqual $resourceGroup.ResourceGroupName $createdAccount.ResourceGroupName
Assert-AreEqual $resourceLocation $createdAccount.Location

$account = Get-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName
Assert-AreEqual $accountName $account.Name
Assert-AreEqual $resourceGroup.ResourceGroupName $account.ResourceGroupName
Assert-AreEqual $resourceLocation $account.Location

Assert-ThrowsContains { New-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Force } "Parameter set cannot be resolved using the specified named parameters."

$old = Get-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName
$new = New-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Primary -Force
Assert-AreNotEqual $old.PrimaryKey $new.PrimaryKey

$old = $new
$new = New-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Secondary -Force
Assert-AreNotEqual $old.SecondaryKey $new.SecondaryKey

$accountRemoved = Remove-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -PassThru
Assert-True{$accountRemoved}

Assert-ThrowsContains { Get-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName } "NotFound"

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Create Get and Delete Spatial Anchors Account
#>
function Test-SpatialAnchorsAccountOperationsWithPiping
{
$resourceGroup = TestSetup-CreateResourceGroup
$resourceLocation = "EastUS2"
$accountName = getAssetName

$createdAccount = New-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Location $resourceLocation
Assert-AreEqual $accountName $createdAccount.Name
Assert-AreEqual $resourceGroup.ResourceGroupName $createdAccount.ResourceGroupName
Assert-AreEqual $resourceLocation $createdAccount.Location

Assert-ThrowsContains { $createdAccount | New-AzSpatialAnchorsAccountKey -Force } "Parameter set cannot be resolved using the specified named parameters."

$old = $createdAccount | Get-AzSpatialAnchorsAccountKey
$new = $createdAccount | New-AzSpatialAnchorsAccountKey -Primary -Force
Assert-AreNotEqual $old.PrimaryKey $new.PrimaryKey

$old = $new
$new = $createdAccount | New-AzSpatialAnchorsAccountKey -Secondary -Force
Assert-AreNotEqual $old.SecondaryKey $new.SecondaryKey

$accountRemoved = $createdAccount | Remove-AzSpatialAnchorsAccount -PassThru
Assert-True{$accountRemoved}

Assert-ThrowsContains { Get-AzSpatialAnchorsAccount -Id $createdAccount.Id } "NotFound"

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Endpoint pipeline exercise
#>
function Test-ListSpatialAnchorsAccounts
{
$resourceGroup = TestSetup-CreateResourceGroup
$resourceLocation = "EastUS2"
$accountName = getAssetName

$accounts = Get-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName
$originalCount = $accounts.Count

$createdAccount = New-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Location $resourceLocation
Assert-AreEqual $accountName $createdAccount.Name
Assert-AreEqual $resourceGroup.ResourceGroupName $createdAccount.ResourceGroupName
Assert-AreEqual $resourceLocation $createdAccount.Location

$accounts = Get-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName
Assert-AreEqual $accounts.Count ($originalCount + 1)

$old = Get-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName
$new = New-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Primary -Force
Assert-AreNotEqual $old.PrimaryKey $new.PrimaryKey

$old = $new
$new = New-AzSpatialAnchorsAccountKey -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -Secondary -Force
Assert-AreNotEqual $old.SecondaryKey $new.SecondaryKey

$accountRemoved = Remove-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName -Name $accountName -PassThru
Assert-True{$accountRemoved}

$accounts = Get-AzSpatialAnchorsAccount -ResourceGroupName $resourceGroup.ResourceGroupName
Assert-AreEqual $accounts.Count $originalCount

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}
Loading