From 9d8b96b825c686eea8fcb07db1466952cccdc53d Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 30 Nov 2023 08:49:54 -0800 Subject: [PATCH 1/2] test: WhereNotNull --- .../Extensions/SystemLinqExtensionsTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs diff --git a/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs b/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs new file mode 100644 index 0000000..c458703 --- /dev/null +++ b/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs @@ -0,0 +1,16 @@ +using Xunit; + +namespace IntelliTect.Multitool.Extensions.Tests; + +public class SystemLinqExtensionsTests +{ + private static readonly List stringsWithSomeNullValues = ["Hello", null, "World", null, "!"]; + + [Fact] + public void WhereNotNull_ReturnsOnlyNonNullValues() + { + IEnumerable nonNullableStringType = stringsWithSomeNullValues.WhereNotNull(); + Assert.All(stringsWithSomeNullValues.WhereNotNull(), s => Assert.NotNull(s)); + Assert.Equal(new List { "Hello", "World", "!" }, nonNullableStringType); + } +} From b585f26bf57e7aa41dd5e5d47e64df31a9790a6e Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 30 Nov 2023 09:04:15 -0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Kevin B --- .../Extensions/SystemLinqExtensionsTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs b/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs index c458703..7b7d4aa 100644 --- a/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs +++ b/IntelliTect.Multitool.Tests/Extensions/SystemLinqExtensionsTests.cs @@ -4,13 +4,13 @@ namespace IntelliTect.Multitool.Extensions.Tests; public class SystemLinqExtensionsTests { - private static readonly List stringsWithSomeNullValues = ["Hello", null, "World", null, "!"]; + private static readonly List _stringsWithSomeNullValues = ["Hello", null, "World", null, "!"]; [Fact] public void WhereNotNull_ReturnsOnlyNonNullValues() { - IEnumerable nonNullableStringType = stringsWithSomeNullValues.WhereNotNull(); - Assert.All(stringsWithSomeNullValues.WhereNotNull(), s => Assert.NotNull(s)); - Assert.Equal(new List { "Hello", "World", "!" }, nonNullableStringType); + IEnumerable nonNullableStringType = _stringsWithSomeNullValues.WhereNotNull(); + Assert.All(_stringsWithSomeNullValues.WhereNotNull(), s => Assert.NotNull(s)); + Assert.Equal(["Hello", "World", "!" ], nonNullableStringType); } }