forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dae736
commit 7d7e1cf
Showing
2 changed files
with
31 additions
and
2 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
23 changes: 23 additions & 0 deletions
23
sdk/eventgrid/Azure.ResourceManager.EventGrid/tests/Unit/ResourceIdentifierExtensionTests.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,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Core; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.ResourceManager.EventGrid.Tests.Unit | ||
{ | ||
public class ResourceIdentifierExtensionTests | ||
{ | ||
[TestCase("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.EventGrid/parents/parentName", "Microsoft.EventGrid", "parents", "parentName")] | ||
[TestCase("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.EventGrid/parents/parentName/children/childName", "Microsoft.EventGrid", "parents/parentName/children", "childName")] | ||
public void ValidateSplitResourceIdentifierIntoParts(string rawId, string ns, string parentName, string name) | ||
{ | ||
var scope = new ResourceIdentifier(rawId); | ||
var parentPart = scope.Parent.SubstringAfterProviderNamespace(); | ||
var actualParentName = (string.IsNullOrEmpty(parentPart) ? string.Empty : $"{parentPart}/") + scope.ResourceType.GetLastType(); | ||
Assert.AreEqual(ns, scope.ResourceType.Namespace); | ||
Assert.AreEqual(parentName, actualParentName); | ||
Assert.AreEqual(name, scope.Name); | ||
} | ||
} | ||
} |