Skip to content

Commit dc9983c

Browse files
authored
add test cases for Resources track 2 mgmt sdk (Azure#12765)
* add test cases for Resources track 2 mgmt sdk * minor update
1 parent 37fec4d commit dc9983c

File tree

352 files changed

+1085483
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+1085483
-9
lines changed

common/ManagementTestShared/ManagementRecordedTestBase.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using System;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
84
using Azure.Core;
95
using Azure.Core.TestFramework;
6+
#if RESOURCES_RP
7+
using Azure.ResourceManager.Resources;
8+
#else
109
using Azure.Management.Resources;
10+
#endif
11+
using System;
12+
using System.Linq;
13+
using System.Threading;
14+
using System.Threading.Tasks;
1115

1216
namespace Azure.ResourceManager.TestFramework
1317
{
@@ -77,5 +81,12 @@ protected async Task<string> GetFirstUsableLocationAsync(ProvidersOperations pro
7781
}
7882
).First().Locations.FirstOrDefault();
7983
}
84+
85+
protected void SleepInTest(int milliSeconds)
86+
{
87+
if (Mode == RecordedTestMode.Playback)
88+
return;
89+
Thread.Sleep(milliSeconds);
90+
}
8091
}
8192
}

sdk/resources/Azure.ResourceManager.Resources/src/DeploymentProperties.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ namespace Azure.ResourceManager.Resources.Models
1010
public partial class DeploymentProperties
1111
{
1212
[CodeGenMember("Template")]
13-
internal JsonElement TemplateJson { get; set; }
13+
internal JsonElement TemplateJson { get; set; } = JsonDocument.Parse("null").RootElement;
1414

1515
[CodeGenMember("Parameters")]
16-
internal JsonElement ParametersJson { get; set; }
16+
internal JsonElement ParametersJson { get; set; } = JsonDocument.Parse("null").RootElement;
1717

1818
/// <summary>
1919
/// Template

sdk/resources/Azure.ResourceManager.Resources/src/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Resources")]
77

8-
[assembly: InternalsVisibleTo("Azure.ResourceManager.Resource.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]
8+
[assembly: InternalsVisibleTo("Azure.ResourceManager.Resources.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<DefineConstants>$(DefineConstants);RESOURCES_RP</DefineConstants>
4+
<TestHelperProjects>;</TestHelperProjects>
5+
</PropertyGroup>
6+
<PropertyGroup>
7+
<NoWarn>SA1649</NoWarn>
8+
</PropertyGroup>
29
<ItemGroup>
310
<ProjectReference Include="..\src\Azure.ResourceManager.Resources.csproj" />
411
</ItemGroup>
12+
<ItemGroup>
13+
<None Update="ScenarioTests\*.json">
14+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
15+
</None>
16+
</ItemGroup>
517
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
6+
namespace Azure.ResourceManager.Resources.Tests
7+
{
8+
public static class Utilities
9+
{
10+
/// <summary>
11+
/// Equality comparison for locations returned by resource management
12+
/// </summary>
13+
/// <param name="expected">The expected location</param>
14+
/// <param name="actual">The actual location returned by resource management</param>
15+
/// <returns>true if the locations are equivalent, otherwise false</returns>
16+
public static bool LocationsAreEqual(string expected, string actual)
17+
{
18+
bool result = string.Equals(expected, actual, System.StringComparison.OrdinalIgnoreCase);
19+
if (!result && !string.IsNullOrEmpty(expected))
20+
{
21+
string normalizedLocation = expected.ToLower().Replace(" ", null);
22+
result = string.Equals(normalizedLocation, actual, StringComparison.OrdinalIgnoreCase);
23+
}
24+
25+
return result;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)