Replaced [MaybeNullWhen(false)] with [NotNullWhen(true)] for UdiParser.TryParse method (#14880)

* Replaced [MaybeNullWhen(false)] with [NotNullWhen(true)] for UdiParser.TryParse method

* Removing some empty lines
This commit is contained in:
Anders Bjerner
2023-10-03 14:43:54 +02:00
committed by GitHub
parent 511ee96c9e
commit 4932119807
2 changed files with 26 additions and 4 deletions

View File

@@ -205,6 +205,28 @@ public class UdiTests
Assert.Throws<ArgumentException>(() => new UdiRange(guidUdi, "x"));
}
[Test]
public void TryParseTest()
{
// try parse to "Udi"
var stringUdiString = "umb://document/b9a56165-6c4e-4e79-8277-620430174ad3";
Assert.IsTrue(UdiParser.TryParse(stringUdiString, out Udi udi1));
Assert.AreEqual("b9a56165-6c4e-4e79-8277-620430174ad3", udi1 is GuidUdi guidUdi1 ? guidUdi1.Guid.ToString() : string.Empty);
// try parse to "Udi"
Assert.IsFalse(UdiParser.TryParse("nope", out Udi udi2));
Assert.IsNull(udi2);
// try parse to "GuidUdi?"
Assert.IsTrue(UdiParser.TryParse(stringUdiString, out GuidUdi? guidUdi3));
Assert.AreEqual("b9a56165-6c4e-4e79-8277-620430174ad3", guidUdi3.Guid.ToString());
// try parse to "GuidUdi?"
Assert.IsFalse(UdiParser.TryParse("nope", out GuidUdi? guidUdi4));
Assert.IsNull(guidUdi4);
}
[Test]
public void SerializationTest()
{