Skip to content

Commit 157c014

Browse files
skadhiresanscbedd
andauthored
Testing for DataBoundary .NET SDKs (Azure#46614)
* added tests * updated tests to using Client * update assets.json with new recording * adding assert * format --------- Co-authored-by: Scott Beddall <[email protected]>
1 parent c39dc72 commit 157c014

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

sdk/resources/Azure.ResourceManager.Resources/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/resources/Azure.ResourceManager.Resources",
5-
"Tag": "net/resources/Azure.ResourceManager.Resources_581adacbe8"
5+
"Tag": "net/resources/Azure.ResourceManager.Resources_58ecd150d6"
66
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Threading.Tasks;
6+
using Azure.Core;
7+
using Azure.Core.TestFramework;
8+
using Azure.Identity;
9+
using Azure.ResourceManager.Resources.Models;
10+
using NUnit.Framework;
11+
12+
namespace Azure.ResourceManager.Resources.Tests
13+
{
14+
public class DataBoundaryOperationsTests : ResourcesTestBase
15+
{
16+
public DataBoundaryOperationsTests(bool isAsync)
17+
: base(isAsync)//, RecordedTestMode.Record
18+
{
19+
}
20+
21+
[TestCase]
22+
[RecordedTest]
23+
public async Task GetDataBoundaryTenant()
24+
{
25+
DataBoundaryName name = DataBoundaryName.Default;
26+
ResourceIdentifier tenantDataBoundaryResourceId = TenantDataBoundaryResource.CreateResourceIdentifier(name);
27+
TenantDataBoundaryResource tenantDataBoundary = Client.GetTenantDataBoundaryResource(tenantDataBoundaryResourceId);
28+
29+
TenantDataBoundaryResource result = await tenantDataBoundary.GetAsync();
30+
31+
DataBoundaryData resourceData = result.Data;
32+
33+
Assert.AreEqual(DataBoundaryRegion.EU, resourceData.Properties.DataBoundary);
34+
}
35+
36+
[TestCase]
37+
[RecordedTest]
38+
public async Task GetDataBoundaryScoped()
39+
{
40+
DataBoundaryName name = DataBoundaryName.Default;
41+
string scope = "/subscriptions/2145a411-d149-4010-84d4-40fe8a55db44";
42+
ResourceIdentifier resourceId = DataBoundaryResource.CreateResourceIdentifier(scope, name);
43+
DataBoundaryResource dataBoundary = Client.GetDataBoundaryResource(resourceId);
44+
DataBoundaryResource result = await dataBoundary.GetAsync(name);
45+
DataBoundaryData resourceData = result.Data;
46+
Assert.AreEqual(DataBoundaryRegion.Global, resourceData.Properties.DataBoundary);
47+
Assert.AreEqual(DataBoundaryProvisioningState.Succeeded, resourceData.Properties.ProvisioningState);
48+
}
49+
50+
[TestCase]
51+
[RecordedTest]
52+
public async Task GetDataBoundaryScopedCollection()
53+
{
54+
DataBoundaryName name = DataBoundaryName.Default;
55+
string scope = "subscriptions/2145a411-d149-4010-84d4-40fe8a55db44";
56+
ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope));
57+
DataBoundaryCollection collection = Client.GetDataBoundaries(scopeId);
58+
59+
DataBoundaryResource result = await collection.GetAsync(name);
60+
61+
DataBoundaryData resourceData = result.Data;
62+
63+
Assert.AreEqual(DataBoundaryRegion.Global, resourceData.Properties.DataBoundary);
64+
Assert.AreEqual(DataBoundaryProvisioningState.Succeeded, resourceData.Properties.ProvisioningState);
65+
}
66+
67+
[TestCase]
68+
[RecordedTest]
69+
public void PutDataBoundary()
70+
{
71+
DataBoundaryName name = DataBoundaryName.Default;
72+
ResourceIdentifier tenantDataBoundaryResourceId = TenantDataBoundaryResource.CreateResourceIdentifier(name);
73+
TenantDataBoundaryResource tenantDataBoundary = Client.GetTenantDataBoundaryResource(tenantDataBoundaryResourceId);
74+
75+
DataBoundaryData data = new DataBoundaryData()
76+
{
77+
Properties = new DataBoundaryProperties()
78+
{
79+
DataBoundary = DataBoundaryRegion.EU,
80+
}
81+
};
82+
83+
var ex = Assert.ThrowsAsync<RequestFailedException>(async () => await tenantDataBoundary.UpdateAsync(WaitUntil.Completed, data));
84+
Assert.IsTrue(ex.Message.Contains("does not have authorization to perform action"));
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)