Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ public static implicit operator ResourceType(string other)
return new ResourceType(other);
}

/// <summary>
/// Implicit operator for initializing a string from a <see cref="ResourceType"/>.
/// </summary>
/// <param name="other"> <see cref="ResourceType"/> to be converted into a string. </param>
public static implicit operator string(ResourceType other)
{
if (other is null)
return null;

return other.ToString();
}

/// <summary>
/// Compares two <see cref="ResourceType"/> objects.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public void NullImplicitFromString()
Assert.IsNull(to);
}

[TestCase]
public void NullImplicitTotring()
{
ResourceType from = null;
string to = from;

Assert.IsNull(to);
}

[TestCase(false, null, "Microsoft.Network1/VirtualNetworks2/subnets1")]
[TestCase(false, "Microsoft.Network1/VirtualNetworks2/subnets1", null)]
[TestCase(true, null, null)]
Expand Down Expand Up @@ -230,5 +239,18 @@ public void EqualsWithObjectString(bool expected, string left, string right)
object rightObject = right;
Assert.AreEqual(expected, rt.Equals(rightObject));
}

[TestCase("Microsoft.classicStorage/storageAccounts")]
[TestCase("Microsoft.ClassicStorage/diffaccount")]
[TestCase("Microsoft.ClassicStorage/storageAccounts")]
[TestCase(null)]
[TestCase("Foo.Bar/puppies")]
public void ImplicitToString(string expected)
{
ResourceType type = expected;
string actual = type;

Assert.AreEqual(expected, actual);
}
}
}