public void CompateToParent(int expected, string resource1, string resource2) { ResourceType resourceType1 = new ResourceType(resource1); ResourceType resourceType2 = new ResourceType(resource2); Assert.AreEqual(expected, resourceType1.CompareTo(resourceType2)); }
public void CompateToNull() { ResourceType resourceType1 = new ResourceType("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRg/providers/Microsoft.ClassicStorage/storageAccounts/account1"); ResourceType resourceType2 = null; Assert.AreEqual(1, resourceType1.CompareTo(resourceType2)); }
public void CompareToNulString() { string other = null; ResourceType rt = "Microsoft.Network1/VirtualNetworks2/subnets1"; Assert.AreEqual(1, rt.CompareTo(other)); }
/// <summary> /// Compare this <see cref="AResourceKey"/> to another <see cref="IResourceKey"/> for sort order purposes /// </summary> /// <param name="other">Target <see cref="IResourceKey"/></param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings: /// <table> /// <thead><tr><td><strong>Value</strong></td><td><strong>Meaning</strong></td></tr></thead> /// <tbody> /// <tr><td>Less than zero</td><td>This instance is less than <paramref name="other"/>.</td></tr> /// <tr><td>Zero</td><td>This instance is equal to <paramref name="other"/>.</td></tr> /// <tr><td>Greater than zero</td><td>This instance is greater than <paramref name="other"/>.</td></tr> /// </tbody> /// </table> /// </returns> /// <exception cref="NotImplementedException">Either this object's Type or the target's is not comparable</exception> /// <exception cref="ArgumentException">The target is not comparable with this object</exception> public int CompareTo(IResourceKey other) { int res = ResourceType.CompareTo(other.ResourceType); if (res != 0) { return(res); } res = ResourceGroup.CompareTo(other.ResourceGroup); if (res != 0) { return(res); } return(Instance.CompareTo(other.Instance)); }