Minor test improvements
MODIFY
src/Chapter06.Tests/Listing06.36.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs
src/Chapter06.Tests/Listing06.36.UsingNotNullWhenAndNotNullIfNotNullAttributes.Tests.cs
@@ -8,11 +8,9 @@ public class NullabilityAttributesExaminedTests
[TestMethod]
public void TryGetAsText_Given4_ReturnFour()
{
- if(NullabilityAttributesExamined.TryGetDigitAsText('4', out string? text))
- {
+ Assert.IsTrue(NullabilityAttributesExamined.TryGetDigitAsText('4', out string? text));
Assert.AreEqual<string>("four", text);
}
- }
[TestMethod]

MODIFY
src/Chapter06.Tests/Listing06.37.UsingTheMaybeNullAttribute.Tests.cs
src/Chapter06.Tests/Listing06.37.UsingTheMaybeNullAttribute.Tests.cs
@@ -8,8 +8,8 @@ public class ProgramTests
[TestMethod]
public void GetObject_CollectionWithItem_ReturnItem()
{
- NullabilityAttributesExamined.GetObject(
- new string[] { "item" }, item => item is object);
+ Assert.IsNull(NullabilityAttributesExamined.GetObject(
+ new string[] { "item" }, item => item is object));
}
[TestMethod]

Minor test improvements