-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5521 - Rename TryGetValue to TryGet/TryGetAsync (#19478)
* Rename TryGetValue to TryGet/TryGetAsync * Update ContainerBase.cs * Update ContainerBase.cs * Update TryGet method and test class * Update CheckResourceExists.cs * Rename TryGetValue to TryGet/TryGetAsync * Update ContainerBase.cs * Update ContainerBase.cs * Update TryGet method and test class * Update CheckResourceExists.cs * Update ContainerBaseTest.cs * Update TryGet Test * Update tests
- Loading branch information
1 parent
420eb02
commit 5621199
Showing
9 changed files
with
1,067 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ContainerTryGetTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
using System; | ||
using System.Threading.Tasks; | ||
using Azure.Identity; | ||
using Azure.Core.TestFramework; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.ResourceManager.Core.Tests | ||
{ | ||
public class ContainerTryGetTest : ResourceManagerTestBase | ||
{ | ||
private AzureResourceManagerClient _client; | ||
private ResourceGroupContainer _container; | ||
private ResourceGroup _resourceGroup; | ||
private string _rgName; | ||
|
||
public ContainerTryGetTest(bool isAsync) | ||
: base(isAsync)//, RecordedTestMode.Record) | ||
{ | ||
} | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_rgName = Recording.GenerateAssetName("CoreRg"); | ||
_client = GetArmClient(); | ||
_container = _client.DefaultSubscription.GetResourceGroupContainer(); | ||
_resourceGroup = _container.Construct(LocationData.WestUS2).CreateOrUpdate(_rgName); | ||
} | ||
|
||
[TestCase] | ||
[RecordedTest] | ||
public void TryGetTest() | ||
{ | ||
ResourceGroup result = _container.TryGet(_rgName); | ||
Assert.NotNull(result); | ||
Assert.IsTrue(result.Data.Name == _rgName); | ||
result = _container.TryGet("FakeName"); | ||
Assert.IsNull(result); | ||
} | ||
|
||
[TestCase] | ||
[RecordedTest] | ||
public async Task TryGetAsyncTest() | ||
{ | ||
ResourceGroup result = await _container.TryGetAsync(_rgName); | ||
Assert.NotNull(result); | ||
Assert.IsTrue(result.Data.Name == _rgName); | ||
result = await _container.TryGetAsync("FakeName"); | ||
Assert.IsNull(result); | ||
} | ||
|
||
[TestCase] | ||
public void DoesExistTest() | ||
{ | ||
Assert.IsTrue(_container.DoesExist(_rgName)); | ||
Assert.IsFalse(_container.DoesExist("FakeName")); | ||
} | ||
} | ||
} |
162 changes: 162 additions & 0 deletions
162
.../Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest().json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.