From c7461accff974009a11d569ee238507238434b45 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Mon, 20 Sep 2021 23:54:31 +0300 Subject: [PATCH 1/5] v2.0.0-preview.2.0.0: Split Primitives --- .../Primitives.Linq.Tests.csproj | 26 ++++++++++ .../TestData/ObjectTestData.cs | 21 ++++++++ .../YieldExtensionsTest.Single.cs | 32 ++++++++++++ .../YieldExtensionsTest.cs | 8 +++ .../YielderTest/YielderTest.Empty.cs | 18 +++++++ .../YielderTest/YielderTest.Single.cs | 32 ++++++++++++ .../YielderTest/YielderTest.cs | 8 +++ .../YielderTypedTest.Empty.cs | 18 +++++++ .../YielderTypedTest.Single.cs | 32 ++++++++++++ .../YielderTypedTest/YielderTypedTest.cs | 8 +++ .../Primitives.Linq/Primitives.Linq.csproj | 26 ++++++++++ .../Primitives.Linq}/YieldExtensions.cs | 0 .../Primitives.Linq}/Yielder.T.cs | 0 .../Primitives.Linq}/Yielder.cs | 0 .../Pipeline.Tests/Pipe.cs | 19 +++++++ .../Pipeline.Tests/Tests.cs | 28 ++++++++++ .../PipelineExtensions.Tests/Pipe.cs | 22 ++++++++ .../PipelineExtensions.Tests/Tests.cs | 28 ++++++++++ .../Primitives.Pipeline.Tests.csproj | 26 ++++++++++ .../Primitives.Pipeline/Pipeline.cs} | 2 +- .../PipelineExtensions.cs} | 2 +- .../Primitives.Pipeline.csproj | 26 ++++++++++ .../IsNotNullOrEmpty.cs | 40 +++++++++++++++ .../IsNotNullOrWhiteSpace.cs | 49 ++++++++++++++++++ .../IsNotNull_Anonymous.cs | 23 +++++++++ .../IsNotNull_NonnullableStruct.cs | 20 ++++++++ .../IsNotNull_NullableStruct.cs | 48 +++++++++++++++++ .../IsNotNull_RefType.cs | 30 +++++++++++ .../IsNotNull_String.cs | 31 +++++++++++ .../IsNullOrEmpty.cs | 40 +++++++++++++++ .../IsNullOrWhiteSpace.cs | 49 ++++++++++++++++++ .../IsNull_Anonymous.cs | 23 +++++++++ .../IsNull_Nonnullable.cs | 20 ++++++++ .../IsNull_NullableStruct.cs | 48 +++++++++++++++++ .../IsNull_RefType.cs | 29 +++++++++++ .../IsNull_String.cs | 31 +++++++++++ .../PredicateExtensions.Tests/Tests.cs | 8 +++ .../Predicates.Tests/IsNotNullOrEmpty.cs | 40 +++++++++++++++ .../Predicates.Tests/IsNotNullOrWhiteSpace.cs | 49 ++++++++++++++++++ .../Predicates.Tests/IsNotNull_Anonymous.cs | 23 +++++++++ .../IsNotNull_NonnullableStruct.cs | 22 ++++++++ .../IsNotNull_NullableStruct.cs | 51 +++++++++++++++++++ .../Predicates.Tests/IsNotNull_RefType.cs | 29 +++++++++++ .../Predicates.Tests/IsNotNull_String.cs | 31 +++++++++++ .../Predicates.Tests/IsNullOrEmpty.cs | 40 +++++++++++++++ .../Predicates.Tests/IsNullOrWhiteSpace.cs | 49 ++++++++++++++++++ .../Predicates.Tests/IsNull_Anonymous.cs | 23 +++++++++ .../IsNull_NonnullableStruct.cs | 22 ++++++++ .../Predicates.Tests/IsNull_NullableStruct.cs | 51 +++++++++++++++++++ .../Predicates.Tests/IsNull_RefType.cs | 30 +++++++++++ .../Predicates.Tests/IsNull_String.cs | 31 +++++++++++ .../Predicates.Tests/Tests.cs | 8 +++ .../Primitives.Predicates.Tests.csproj | 26 ++++++++++ .../PredicateExtensions.Null.Struct.cs | 0 .../PredicateExtensions.Null.cs | 0 .../PredicateExtensions.NullOrEmpty.cs | 0 .../PredicateExtensions.NullOrWhiteSpace.cs | 0 .../PredicateExtensions.cs | 0 .../Predicates/Predicates.Null.Struct.cs | 0 .../Predicates/Predicates.Null.cs | 0 .../Predicates/Predicates.NullOrEmpty.cs | 0 .../Predicates/Predicates.NullOrWhiteSpace.cs | 0 .../Predicates/Predicates.cs | 0 .../Primitives.Predicates.csproj | 26 ++++++++++ .../Primitives.Strings.Tests.csproj | 26 ++++++++++ .../StringExtensions.Tests/OrEmpty.cs | 32 ++++++++++++ .../StringExtensions.Tests/OrNullIfEmpty.cs | 32 ++++++++++++ .../OrNullIfWhiteSpace.cs | 33 ++++++++++++ .../StringExtensions.Tests/Tests.cs | 8 +++ .../ToStringOrEmpty_Ref.cs | 43 ++++++++++++++++ .../ToStringOrEmpty_StructNullable.cs | 43 ++++++++++++++++ .../Strings.Tests/Empty.cs | 24 +++++++++ .../Strings.Tests/OrEmpty.cs | 32 ++++++++++++ .../Strings.Tests/OrNullIfEmpty.cs | 32 ++++++++++++ .../Strings.Tests/OrNullIfWhiteSpace.cs | 33 ++++++++++++ .../Strings.Tests/Tests.cs | 8 +++ .../Strings.Tests/ToStringOrEmpty_Ref.cs | 43 ++++++++++++++++ .../ToStringOrEmpty_StructNullable.cs | 43 ++++++++++++++++ .../Stubs/ToStringStubRefType.cs | 15 ++++++ .../Stubs/ToStringStubStructType.cs | 15 ++++++ .../Primitives.Strings.csproj | 26 ++++++++++ .../Primitives.Strings}/StringExtensions.cs | 0 .../Primitives.Strings}/Strings.cs | 0 .../Primitives/Pipeline/Pipeline.cs | 8 --- .../Primitives/Pipeline/PipelineExtensions.cs | 8 --- src/primitives/Primitives/Primitives.csproj | 11 +++- 86 files changed, 1917 insertions(+), 20 deletions(-) create mode 100644 src/primitives-linq/Primitives.Linq.Tests/Primitives.Linq.Tests.csproj create mode 100644 src/primitives-linq/Primitives.Linq.Tests/TestData/ObjectTestData.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.Single.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Empty.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Single.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Empty.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Single.cs create mode 100644 src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.cs create mode 100644 src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj rename src/{primitives/Primitives/Linq => primitives-linq/Primitives.Linq}/YieldExtensions.cs (100%) rename src/{primitives/Primitives/Linq => primitives-linq/Primitives.Linq}/Yielder.T.cs (100%) rename src/{primitives/Primitives/Linq => primitives-linq/Primitives.Linq}/Yielder.cs (100%) create mode 100644 src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Pipe.cs create mode 100644 src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Tests.cs create mode 100644 src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Pipe.cs create mode 100644 src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Tests.cs create mode 100644 src/primitives-pipeline/Primitives.Pipeline.Tests/Primitives.Pipeline.Tests.csproj rename src/{primitives/Primitives/Pipeline/Pipeline.Pipe.cs => primitives-pipeline/Primitives.Pipeline/Pipeline.cs} (86%) rename src/{primitives/Primitives/Pipeline/PipelineExtensions.Pipe.cs => primitives-pipeline/Primitives.Pipeline/PipelineExtensions.cs} (89%) create mode 100644 src/primitives-pipeline/Primitives.Pipeline/Primitives.Pipeline.csproj create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrEmpty.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrWhiteSpace.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_Anonymous.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NonnullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_RefType.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_String.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrEmpty.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrWhiteSpace.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Anonymous.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Nonnullable.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_NullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_RefType.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_String.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/Tests.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrEmpty.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrWhiteSpace.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_Anonymous.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NonnullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_RefType.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_String.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrEmpty.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrWhiteSpace.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_Anonymous.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NonnullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NullableStruct.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_RefType.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_String.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/Tests.cs create mode 100644 src/primitives-predicates/Primitives.Predicates.Tests/Primitives.Predicates.Tests.csproj rename src/{primitives/Primitives/Predicates => primitives-predicates/Primitives.Predicates/PredicateExtensions}/PredicateExtensions.Null.Struct.cs (100%) rename src/{primitives/Primitives/Predicates => primitives-predicates/Primitives.Predicates/PredicateExtensions}/PredicateExtensions.Null.cs (100%) rename src/{primitives/Primitives/Predicates => primitives-predicates/Primitives.Predicates/PredicateExtensions}/PredicateExtensions.NullOrEmpty.cs (100%) rename src/{primitives/Primitives/Predicates => primitives-predicates/Primitives.Predicates/PredicateExtensions}/PredicateExtensions.NullOrWhiteSpace.cs (100%) rename src/{primitives/Primitives/Predicates => primitives-predicates/Primitives.Predicates/PredicateExtensions}/PredicateExtensions.cs (100%) rename src/{primitives/Primitives => primitives-predicates/Primitives.Predicates}/Predicates/Predicates.Null.Struct.cs (100%) rename src/{primitives/Primitives => primitives-predicates/Primitives.Predicates}/Predicates/Predicates.Null.cs (100%) rename src/{primitives/Primitives => primitives-predicates/Primitives.Predicates}/Predicates/Predicates.NullOrEmpty.cs (100%) rename src/{primitives/Primitives => primitives-predicates/Primitives.Predicates}/Predicates/Predicates.NullOrWhiteSpace.cs (100%) rename src/{primitives/Primitives => primitives-predicates/Primitives.Predicates}/Predicates/Predicates.cs (100%) create mode 100644 src/primitives-predicates/Primitives.Predicates/Primitives.Predicates.csproj create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Primitives.Strings.Tests.csproj create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrEmpty.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfEmpty.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfWhiteSpace.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/Tests.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_Ref.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_StructNullable.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Empty.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrEmpty.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfEmpty.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfWhiteSpace.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Tests.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_Ref.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_StructNullable.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubRefType.cs create mode 100644 src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubStructType.cs create mode 100644 src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj rename src/{primitives/Primitives/Strings => primitives-strings/Primitives.Strings}/StringExtensions.cs (100%) rename src/{primitives/Primitives/Strings => primitives-strings/Primitives.Strings}/Strings.cs (100%) delete mode 100644 src/primitives/Primitives/Pipeline/Pipeline.cs delete mode 100644 src/primitives/Primitives/Pipeline/PipelineExtensions.cs diff --git a/src/primitives-linq/Primitives.Linq.Tests/Primitives.Linq.Tests.csproj b/src/primitives-linq/Primitives.Linq.Tests/Primitives.Linq.Tests.csproj new file mode 100644 index 00000000..66bf443d --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/Primitives.Linq.Tests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + false + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack.Primitives.Tests + PrimeFuncPack.Primitives.Linq.Tests + + + + + + + + + + + + + + diff --git a/src/primitives-linq/Primitives.Linq.Tests/TestData/ObjectTestData.cs b/src/primitives-linq/Primitives.Linq.Tests/TestData/ObjectTestData.cs new file mode 100644 index 00000000..4439b6e2 --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/TestData/ObjectTestData.cs @@ -0,0 +1,21 @@ +#nullable enable + +using System.Collections.Generic; +using System.Linq; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + internal static class ObjectTestData + { + public static IEnumerable NullableObjectTestSource + => + new object?[] + { + null, + PlusFifteenIdRefType, + SomeTextStructType + } + .Select(v => new object?[] { v }); + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.Single.cs b/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.Single.cs new file mode 100644 index 00000000..4280e14f --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.Single.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class YieldExtensionsTest + { + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectCollectionLengthEqualsOne( + object? sourceValue) + { + var actual = sourceValue.YieldSingle(); + + var actualLength = actual.Count(); + Assert.AreEqual(1, actualLength); + } + + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectFirstItemIsSameAsSourceValue( + object? sourceValue) + { + var actual = sourceValue.YieldSingle(); + + var actualFirst = actual.FirstOrDefault(); + Assert.AreSame(sourceValue, actualFirst); + } + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.cs b/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.cs new file mode 100644 index 00000000..6601fb00 --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YieldExtensionsTest/YieldExtensionsTest.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class YieldExtensionsTest + { + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Empty.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Empty.cs new file mode 100644 index 00000000..cd00947d --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Empty.cs @@ -0,0 +1,18 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class YielderTest + { + [Test] + public void YieldEmpty_ExpectEmptyCollection() + { + var actual = Yielder.YieldEmpty(); + Assert.IsEmpty(actual); + } + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Single.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Single.cs new file mode 100644 index 00000000..e23bf63b --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.Single.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class YielderTest + { + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectCollectionLengthEqualsOne( + object? sourceValue) + { + var actual = Yielder.YieldSingle(sourceValue); + + var actualLength = actual.Count(); + Assert.AreEqual(1, actualLength); + } + + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectFirstItemIsSameAsSourceValue( + object? sourceValue) + { + var actual = Yielder.YieldSingle(sourceValue); + + var actualFirst = actual.FirstOrDefault(); + Assert.AreSame(sourceValue, actualFirst); + } + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.cs new file mode 100644 index 00000000..b57d1e38 --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTest/YielderTest.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class YielderTest + { + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Empty.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Empty.cs new file mode 100644 index 00000000..67260ac5 --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Empty.cs @@ -0,0 +1,18 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class YielderTypedTest + { + [Test] + public void YieldEmpty_ExpectEmptyCollection() + { + var actual = Yielder.YieldEmpty(); + Assert.IsEmpty(actual); + } + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Single.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Single.cs new file mode 100644 index 00000000..4266fc43 --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.Single.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class YielderTypedTest + { + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectCollectionLengthEqualsOne( + object? sourceValue) + { + var actual = Yielder.YieldSingle(sourceValue); + + var actualLength = actual.Count(); + Assert.AreEqual(1, actualLength); + } + + [Test] + [TestCaseSource(typeof(ObjectTestData), nameof(ObjectTestData.NullableObjectTestSource))] + public void YieldSingle_ExpectFirstItemIsSameAsSourceValue( + object? sourceValue) + { + var actual = Yielder.YieldSingle(sourceValue); + + var actualFirst = actual.FirstOrDefault(); + Assert.AreSame(sourceValue, actualFirst); + } + } +} diff --git a/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.cs b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.cs new file mode 100644 index 00000000..570d405a --- /dev/null +++ b/src/primitives-linq/Primitives.Linq.Tests/YielderTypedTest/YielderTypedTest.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class YielderTypedTest + { + } +} diff --git a/src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj b/src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj new file mode 100644 index 00000000..80c610dd --- /dev/null +++ b/src/primitives-linq/Primitives.Linq/Primitives.Linq.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + true + true + LICENSE + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack Primitives.Linq is a core library for .NET consisting of useful extensions making work with Linq easier. + System + PrimeFuncPack.Primitives.Linq + 2.0.0-preview.2.0.0 + + + + + True + + + + + diff --git a/src/primitives/Primitives/Linq/YieldExtensions.cs b/src/primitives-linq/Primitives.Linq/YieldExtensions.cs similarity index 100% rename from src/primitives/Primitives/Linq/YieldExtensions.cs rename to src/primitives-linq/Primitives.Linq/YieldExtensions.cs diff --git a/src/primitives/Primitives/Linq/Yielder.T.cs b/src/primitives-linq/Primitives.Linq/Yielder.T.cs similarity index 100% rename from src/primitives/Primitives/Linq/Yielder.T.cs rename to src/primitives-linq/Primitives.Linq/Yielder.T.cs diff --git a/src/primitives/Primitives/Linq/Yielder.cs b/src/primitives-linq/Primitives.Linq/Yielder.cs similarity index 100% rename from src/primitives/Primitives/Linq/Yielder.cs rename to src/primitives-linq/Primitives.Linq/Yielder.cs diff --git a/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Pipe.cs b/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Pipe.cs new file mode 100644 index 00000000..4ecfbd60 --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Pipe.cs @@ -0,0 +1,19 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PipelineTests + { + [Test] + [TestCaseSource(nameof(ValueTestSource))] + public void Pipe_ExpectSourceValue( + object? sourceValue) + { + var actual = Pipeline.Pipe(sourceValue); + Assert.AreSame(sourceValue, actual); + } + } +} diff --git a/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Tests.cs b/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Tests.cs new file mode 100644 index 00000000..48ddae35 --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline.Tests/Pipeline.Tests/Tests.cs @@ -0,0 +1,28 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PipelineTests + { + private static IEnumerable ValueTestSource + => + SourceValues.Select(v => new object?[] { v }); + + private static IReadOnlyCollection SourceValues + => + new object?[] + { + null, + "Some String", + string.Empty, + new DateTime(2020, 09, 25), + (int?)15, + new object(), + new { Id = 1, Text = "Some Text" } + }; + } +} diff --git a/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Pipe.cs b/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Pipe.cs new file mode 100644 index 00000000..45688803 --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Pipe.cs @@ -0,0 +1,22 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PipelineExtensionsTests + { + [Test] + [TestCaseSource(nameof(ValueTestSource))] + public void Pipe_ExpectMappedSourceValue( + object? sourceValue) + { + var actual = sourceValue.Pipe(value => (value, PlusFifteen)); + var expected = (sourceValue, PlusFifteen); + Assert.AreSame(expected.sourceValue, sourceValue); + Assert.AreEqual(expected, actual); + } + } +} diff --git a/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Tests.cs b/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Tests.cs new file mode 100644 index 00000000..2e94aa36 --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline.Tests/PipelineExtensions.Tests/Tests.cs @@ -0,0 +1,28 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PipelineExtensionsTests + { + private static IEnumerable ValueTestSource + => + SourceValues.Select(v => new object?[] { v }); + + private static IReadOnlyCollection SourceValues + => + new object?[] + { + null, + "Some String", + string.Empty, + new DateTime(2020, 09, 25), + (int?)15, + new object(), + new { Id = 1, Text = "Some Text" } + }; + } +} diff --git a/src/primitives-pipeline/Primitives.Pipeline.Tests/Primitives.Pipeline.Tests.csproj b/src/primitives-pipeline/Primitives.Pipeline.Tests/Primitives.Pipeline.Tests.csproj new file mode 100644 index 00000000..a95a451f --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline.Tests/Primitives.Pipeline.Tests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + false + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack.Primitives.Tests + PrimeFuncPack.Primitives.Pipeline.Tests + + + + + + + + + + + + + + diff --git a/src/primitives/Primitives/Pipeline/Pipeline.Pipe.cs b/src/primitives-pipeline/Primitives.Pipeline/Pipeline.cs similarity index 86% rename from src/primitives/Primitives/Pipeline/Pipeline.Pipe.cs rename to src/primitives-pipeline/Primitives.Pipeline/Pipeline.cs index 7b62a777..68cb75bd 100644 --- a/src/primitives/Primitives/Pipeline/Pipeline.Pipe.cs +++ b/src/primitives-pipeline/Primitives.Pipeline/Pipeline.cs @@ -4,7 +4,7 @@ namespace System { - partial class Pipeline + public static class Pipeline { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T Pipe(T value) => value; diff --git a/src/primitives/Primitives/Pipeline/PipelineExtensions.Pipe.cs b/src/primitives-pipeline/Primitives.Pipeline/PipelineExtensions.cs similarity index 89% rename from src/primitives/Primitives/Pipeline/PipelineExtensions.Pipe.cs rename to src/primitives-pipeline/Primitives.Pipeline/PipelineExtensions.cs index 800a43d9..8a95d810 100644 --- a/src/primitives/Primitives/Pipeline/PipelineExtensions.Pipe.cs +++ b/src/primitives-pipeline/Primitives.Pipeline/PipelineExtensions.cs @@ -4,7 +4,7 @@ namespace System { - partial class PipelineExtensions + public static class PipelineExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TResult Pipe(this T value, Func pipe) diff --git a/src/primitives-pipeline/Primitives.Pipeline/Primitives.Pipeline.csproj b/src/primitives-pipeline/Primitives.Pipeline/Primitives.Pipeline.csproj new file mode 100644 index 00000000..377d5a0a --- /dev/null +++ b/src/primitives-pipeline/Primitives.Pipeline/Primitives.Pipeline.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + true + true + LICENSE + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack Primitives.Pipeline is a core library for .NET consisting of useful extensions making work with functional pipelines easier. + System + PrimeFuncPack.Primitives.Pipeline + 2.0.0-preview.2.0.0 + + + + + True + + + + + diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrEmpty.cs new file mode 100644 index 00000000..065f5932 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrEmpty.cs @@ -0,0 +1,40 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNotNullOrEmpty_SourceIsNull_ExpectFalse() + { + string? source = null; + + var actual = source.IsNotNullOrEmpty(); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrEmpty_SourceIsEmpty_ExpectFalse() + { + string source = string.Empty; + + var actual = source.IsNotNullOrEmpty(); + Assert.False(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void IsNotNullOrEmpty_SourceIsNotEmpty_ExpectTrue( + string source) + { + var actual = source.IsNotNullOrEmpty(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrWhiteSpace.cs new file mode 100644 index 00000000..efab0a61 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNullOrWhiteSpace.cs @@ -0,0 +1,49 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNotNullOrWhiteSpace_SourceIsNull_ExpectFalse() + { + string? source = null; + + var actual = source.IsNotNullOrWhiteSpace(); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrWhiteSpace_SourceIsEmpty_ExpectFalse() + { + string source = string.Empty; + + var actual = source.IsNotNullOrWhiteSpace(); + Assert.False(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void IsNotNullOrWhiteSpace_SourceIsWhiteSpace_ExpectFalse( + string source) + { + var actual = source.IsNotNullOrWhiteSpace(); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrWhiteSpace_SourceIsNotWhiteSpace_ExpectTrue() + { + var source = SomeString; + + var actual = source.IsNotNullOrWhiteSpace(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_Anonymous.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_Anonymous.cs new file mode 100644 index 00000000..e27b3b85 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_Anonymous.cs @@ -0,0 +1,23 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNotNull_AnonymousValueIsNotNull_ExpectTrue() + { + var source = new + { + Text = SomeTextStructType + }; + + var actual = source.IsNotNull(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NonnullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NonnullableStruct.cs new file mode 100644 index 00000000..ca047302 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NonnullableStruct.cs @@ -0,0 +1,20 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNotNull_NonnullableStruct_ExpectTrue(int source) + { + var actual = source.IsNotNull(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NullableStruct.cs new file mode 100644 index 00000000..9e5ade32 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_NullableStruct.cs @@ -0,0 +1,48 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNotNull_NullableStructIsNull_CallStructOverload_ExpectFalse() + { + int? source = null; + + var actual = source.IsNotNull(); + Assert.False(actual); + } + + [Test] + public void IsNotNull_NullableStructIsNull_CallObjectOverload_ExpectFalse() + { + int? source = null; + + var actual = source.IsNotNull(); + Assert.False(actual); + } + + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNotNull_NullableStructIsNotNull_CallStructOverload_ExpectTrue(int? source) + { + var actual = source.IsNotNull(); + Assert.True(actual); + } + + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNotNull_NullableStructIsNotNull_CallObjectOverload_ExpectTrue(int? source) + { + var actual = source.IsNotNull(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_RefType.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_RefType.cs new file mode 100644 index 00000000..aff893d9 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_RefType.cs @@ -0,0 +1,30 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNotNull_RefValueIsNull_ExpectFalse() + { + RefType source = null!; + + var actual = source.IsNotNull(); + Assert.False(actual); + } + + [Test] + public void IsNotNull_RefValueIsNotNull_ExpectTrue() + { + var source = MinusFifteenIdRefType; + + var actual = source.IsNotNull(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_String.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_String.cs new file mode 100644 index 00000000..5143fe9b --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNotNull_String.cs @@ -0,0 +1,31 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicateExtensionsTests + { + [Test] + public void IsNotNull_StringIsNull_ExpectFalse() + { + string source = null!; + + var actual = source.IsNotNull(); + Assert.False(actual); + } + + [Test] + [TestCase(TestData.EmptyString)] + [TestCase(TestData.WhiteSpaceString)] + [TestCase(TestData.TabString)] + [TestCase(TestData.SomeString)] + public void IsNotNull_StringIsNotNull_ExpectTrue(string? source) + { + var actual = source.IsNotNull(); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrEmpty.cs new file mode 100644 index 00000000..9e74c3f4 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrEmpty.cs @@ -0,0 +1,40 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNullOrEmpty_SourceIsNull_ExpectTrue() + { + string? source = null; + + var actual = source.IsNullOrEmpty(); + Assert.True(actual); + } + + [Test] + public void IsNullOrEmpty_SourceIsEmpty_ExpectTrue() + { + string source = string.Empty; + + var actual = source.IsNullOrEmpty(); + Assert.True(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void IsNullOrEmpty_SourceIsNotEmpty_ExpectFalse( + string source) + { + var actual = source.IsNullOrEmpty(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrWhiteSpace.cs new file mode 100644 index 00000000..e58a874f --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNullOrWhiteSpace.cs @@ -0,0 +1,49 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNullOrWhiteSpace_SourceIsNull_ExpectTrue() + { + string? source = null; + + var actual = source.IsNullOrWhiteSpace(); + Assert.True(actual); + } + + [Test] + public void IsNullOrWhiteSpace_SourceIsEmpty_ExpectTrue() + { + string source = string.Empty; + + var actual = source.IsNullOrWhiteSpace(); + Assert.True(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void IsNullOrWhiteSpace_SourceIsWhiteSpace_ExpectTrue( + string source) + { + var actual = source.IsNullOrWhiteSpace(); + Assert.True(actual); + } + + [Test] + public void IsNullOrWhiteSpace_SourceIsNotWhiteSpace_ExpectFalse() + { + var source = SomeString; + + var actual = source.IsNullOrWhiteSpace(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Anonymous.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Anonymous.cs new file mode 100644 index 00000000..5c064fb5 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Anonymous.cs @@ -0,0 +1,23 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNull_AnonymousValueIsNotNull_ExpectFalse() + { + var source = new + { + Text = SomeTextStructType + }; + + var actual = source.IsNull(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Nonnullable.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Nonnullable.cs new file mode 100644 index 00000000..64296957 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_Nonnullable.cs @@ -0,0 +1,20 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNull_NonnullableStruct_ExpectFalse(int source) + { + var actual = source.IsNull(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_NullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_NullableStruct.cs new file mode 100644 index 00000000..35188177 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_NullableStruct.cs @@ -0,0 +1,48 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNull_NullableStructIsNull_CallStructOverload_ExpectTrue() + { + int? source = null; + + var actual = source.IsNull(); + Assert.True(actual); + } + + [Test] + public void IsNull_NullableStructIsNull_CallObjectOverload_ExpectTrue() + { + int? source = null; + + var actual = source.IsNull(); + Assert.True(actual); + } + + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNull_NullableStructIsNotNull_CallStructOverload_ExpectFalse(int? source) + { + var actual = source.IsNull(); + Assert.False(actual); + } + + // Test both zero and non-zero values + [Test] + [TestCase(0)] + [TestCase(1)] + public void IsNull_NullableStructIsNotNull_CallObjectOverload_ExpectFalse(int? source) + { + var actual = source.IsNull(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_RefType.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_RefType.cs new file mode 100644 index 00000000..b7c002b1 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_RefType.cs @@ -0,0 +1,29 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicateExtensionsTests + { + [Test] + public void IsNull_RefValueIsNull_ExpectTrue() + { + object source = null!; + + var actual = source.IsNull(); + Assert.True(actual); + } + + [Test] + public void IsNull_RefValueIsNotNull_ExpectFalse() + { + var source = ZeroIdRefType; + + var actual = source.IsNull(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_String.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_String.cs new file mode 100644 index 00000000..f1f783fe --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/IsNull_String.cs @@ -0,0 +1,31 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicateExtensionsTests + { + [Test] + public void IsNull_StringIsNull_ExpectTrue() + { + string source = null!; + + var actual = source.IsNull(); + Assert.True(actual); + } + + [Test] + [TestCase(TestData.EmptyString)] + [TestCase(TestData.WhiteSpaceString)] + [TestCase(TestData.TabString)] + [TestCase(TestData.SomeString)] + public void IsNull_StringIsNotNull_ExpectFalse(string? source) + { + var actual = source.IsNull(); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/Tests.cs b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/Tests.cs new file mode 100644 index 00000000..82f1b598 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/PredicateExtensions.Tests/Tests.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicateExtensionsTests + { + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrEmpty.cs new file mode 100644 index 00000000..d6492a8b --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrEmpty.cs @@ -0,0 +1,40 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNotNullOrEmpty_SourceIsNull_ExpectFalse() + { + string? source = null; + + var actual = Predicates.IsNotNullOrEmpty(source); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrEmpty_SourceIsEmpty_ExpectFalse() + { + string source = string.Empty; + + var actual = Predicates.IsNotNullOrEmpty(source); + Assert.False(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void IsNotNullOrEmpty_SourceIsNotEmpty_ExpectTrue( + string source) + { + var actual = Predicates.IsNotNullOrEmpty(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrWhiteSpace.cs new file mode 100644 index 00000000..65678d6e --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNullOrWhiteSpace.cs @@ -0,0 +1,49 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNotNullOrWhiteSpace_SourceIsNull_ExpectFalse() + { + string? source = null; + + var actual = Predicates.IsNotNullOrWhiteSpace(source); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrWhiteSpace_SourceIsEmpty_ExpectFalse() + { + string source = string.Empty; + + var actual = Predicates.IsNotNullOrWhiteSpace(source); + Assert.False(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void IsNotNullOrWhiteSpace_SourceIsWhiteSpace_ExpectFalse( + string source) + { + var actual = Predicates.IsNotNullOrWhiteSpace(source); + Assert.False(actual); + } + + [Test] + public void IsNotNullOrWhiteSpace_SourceIsNotWhiteSpace_ExpectTrue() + { + var source = SomeString; + + var actual = Predicates.IsNotNullOrWhiteSpace(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_Anonymous.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_Anonymous.cs new file mode 100644 index 00000000..4cf75e0a --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_Anonymous.cs @@ -0,0 +1,23 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + [Test] + public void IsNotNull_AnonymousValueIsNotNull_ExpectTrue() + { + var source = new + { + Text = SomeTextStructType + }; + + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NonnullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NonnullableStruct.cs new file mode 100644 index 00000000..720cea39 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NonnullableStruct.cs @@ -0,0 +1,22 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNotNull_NonnullableStruct_ExpectTrue(int source) + { + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NullableStruct.cs new file mode 100644 index 00000000..2b620749 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_NullableStruct.cs @@ -0,0 +1,51 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + [Test] + public void IsNotNull_NullableStructIsNull_CallStructOverload_ExpectFalse() + { + int? source = null; + + var actual = Predicates.IsNotNull(source); + Assert.False(actual); + } + + [Test] + public void IsNotNull_NullableStructIsNull_CallObjectOverload_ExpectFalse() + { + int? source = null; + + var actual = Predicates.IsNotNull(source); + Assert.False(actual); + } + + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNotNull_NullableStructIsNotNull_CallStructOverload_ExpectTrue(int? source) + { + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNotNull_NullableStructIsNotNull_CallObjectOverload_ExpectTrue(int? source) + { + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_RefType.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_RefType.cs new file mode 100644 index 00000000..8f3234c4 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_RefType.cs @@ -0,0 +1,29 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + [Test] + public void IsNotNull_RefValueIsNull_ExpectFalse() + { + object source = null!; + + var actual = Predicates.IsNotNull(source); + Assert.False(actual); + } + + [Test] + public void IsNotNull_RefValueIsNotNull_ExpectTrue() + { + var source = PlusFifteenIdRefType; + + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_String.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_String.cs new file mode 100644 index 00000000..6754c00b --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNotNull_String.cs @@ -0,0 +1,31 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + [Test] + public void IsNotNull_StringIsNull_ExpectFalse() + { + string source = null!; + + var actual = Predicates.IsNotNull(source); + Assert.False(actual); + } + + [Test] + [TestCase(TestData.EmptyString)] + [TestCase(TestData.WhiteSpaceString)] + [TestCase(TestData.TabString)] + [TestCase(TestData.SomeString)] + public void IsNotNull_StringIsNotNull_ExpectTrue(string? source) + { + var actual = Predicates.IsNotNull(source); + Assert.True(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrEmpty.cs new file mode 100644 index 00000000..fdd345eb --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrEmpty.cs @@ -0,0 +1,40 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNullOrEmpty_SourceIsNull_ExpectTrue() + { + string? source = null; + + var actual = Predicates.IsNullOrEmpty(source); + Assert.True(actual); + } + + [Test] + public void IsNullOrEmpty_SourceIsEmpty_ExpectTrue() + { + string source = string.Empty; + + var actual = Predicates.IsNullOrEmpty(source); + Assert.True(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void IsNullOrEmpty_SourceIsNotEmpty_ExpectFalse( + string source) + { + var actual = Predicates.IsNullOrEmpty(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrWhiteSpace.cs new file mode 100644 index 00000000..8282b7e3 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNullOrWhiteSpace.cs @@ -0,0 +1,49 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNullOrWhiteSpace_SourceIsNull_ExpectTrue() + { + string? source = null; + + var actual = Predicates.IsNullOrWhiteSpace(source); + Assert.True(actual); + } + + [Test] + public void IsNullOrWhiteSpace_SourceIsEmpty_ExpectTrue() + { + string source = string.Empty; + + var actual = Predicates.IsNullOrWhiteSpace(source); + Assert.True(actual); + } + + [Test] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void IsNullOrWhiteSpace_SourceIsWhiteSpace_ExpectTrue( + string source) + { + var actual = Predicates.IsNullOrWhiteSpace(source); + Assert.True(actual); + } + + [Test] + public void IsNullOrWhiteSpace_SourceIsNotWhiteSpace_ExpectFalse() + { + var source = SomeString; + + var actual = Predicates.IsNullOrWhiteSpace(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_Anonymous.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_Anonymous.cs new file mode 100644 index 00000000..34e404f8 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_Anonymous.cs @@ -0,0 +1,23 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNull_AnonymousValueIsNotNull_ExpectFalse() + { + var source = new + { + Text = SomeTextStructType + }; + + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NonnullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NonnullableStruct.cs new file mode 100644 index 00000000..8afa70fa --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NonnullableStruct.cs @@ -0,0 +1,22 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNull_NonnullableStruct_ExpectFalse(int source) + { + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NullableStruct.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NullableStruct.cs new file mode 100644 index 00000000..020b7725 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_NullableStruct.cs @@ -0,0 +1,51 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNull_NullableStructIsNull_CallStructOverload_ExpectTrue() + { + int? source = null; + + var actual = Predicates.IsNull(source); + Assert.True(actual); + } + + [Test] + public void IsNull_NullableStructIsNull_CallObjectOverload_ExpectTrue() + { + int? source = null; + + var actual = Predicates.IsNull(source); + Assert.True(actual); + } + + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNull_NullableStructIsNotNull_CallStructOverload_ExpectFalse(int? source) + { + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + + // Test both some specific cases + [Test] + [TestCase(TestData.MinusOne)] + [TestCase(TestData.Zero)] + [TestCase(TestData.One)] + public void IsNull_NullableStructIsNotNull_CallObjectOverload_ExpectFalse(int? source) + { + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_RefType.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_RefType.cs new file mode 100644 index 00000000..6aa432ad --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_RefType.cs @@ -0,0 +1,30 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class PredicatesTests + { + [Test] + public void IsNull_RefValueIsNull_ExpectTrue() + { + RefType source = null!; + + var actual = Predicates.IsNull(source); + Assert.True(actual); + } + + [Test] + public void IsNull_RefValueIsNull_ExpectFalse() + { + var source = MinusFifteenIdRefType; + + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_String.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_String.cs new file mode 100644 index 00000000..f25843b6 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/IsNull_String.cs @@ -0,0 +1,31 @@ +#nullable enable + +using NUnit.Framework; +using PrimeFuncPack.UnitTest; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + [Test] + public void IsNull_StringIsNull_ExpectTrue() + { + string source = null!; + + var actual = Predicates.IsNull(source); + Assert.True(actual); + } + + [Test] + [TestCase(TestData.EmptyString)] + [TestCase(TestData.WhiteSpaceString)] + [TestCase(TestData.TabString)] + [TestCase(TestData.SomeString)] + public void IsNull_StringIsNotNull_ExpectFalse(string? source) + { + var actual = Predicates.IsNull(source); + Assert.False(actual); + } + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/Tests.cs b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/Tests.cs new file mode 100644 index 00000000..6c287a45 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Predicates.Tests/Tests.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class PredicatesTests + { + } +} diff --git a/src/primitives-predicates/Primitives.Predicates.Tests/Primitives.Predicates.Tests.csproj b/src/primitives-predicates/Primitives.Predicates.Tests/Primitives.Predicates.Tests.csproj new file mode 100644 index 00000000..4e5c9a6b --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates.Tests/Primitives.Predicates.Tests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + false + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack.Primitives.Tests + PrimeFuncPack.Primitives.Predicates.Tests + + + + + + + + + + + + + + diff --git a/src/primitives/Primitives/Predicates/PredicateExtensions.Null.Struct.cs b/src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.Null.Struct.cs similarity index 100% rename from src/primitives/Primitives/Predicates/PredicateExtensions.Null.Struct.cs rename to src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.Null.Struct.cs diff --git a/src/primitives/Primitives/Predicates/PredicateExtensions.Null.cs b/src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.Null.cs similarity index 100% rename from src/primitives/Primitives/Predicates/PredicateExtensions.Null.cs rename to src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.Null.cs diff --git a/src/primitives/Primitives/Predicates/PredicateExtensions.NullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.NullOrEmpty.cs similarity index 100% rename from src/primitives/Primitives/Predicates/PredicateExtensions.NullOrEmpty.cs rename to src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.NullOrEmpty.cs diff --git a/src/primitives/Primitives/Predicates/PredicateExtensions.NullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.NullOrWhiteSpace.cs similarity index 100% rename from src/primitives/Primitives/Predicates/PredicateExtensions.NullOrWhiteSpace.cs rename to src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.NullOrWhiteSpace.cs diff --git a/src/primitives/Primitives/Predicates/PredicateExtensions.cs b/src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.cs similarity index 100% rename from src/primitives/Primitives/Predicates/PredicateExtensions.cs rename to src/primitives-predicates/Primitives.Predicates/PredicateExtensions/PredicateExtensions.cs diff --git a/src/primitives/Primitives/Predicates/Predicates.Null.Struct.cs b/src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.Null.Struct.cs similarity index 100% rename from src/primitives/Primitives/Predicates/Predicates.Null.Struct.cs rename to src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.Null.Struct.cs diff --git a/src/primitives/Primitives/Predicates/Predicates.Null.cs b/src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.Null.cs similarity index 100% rename from src/primitives/Primitives/Predicates/Predicates.Null.cs rename to src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.Null.cs diff --git a/src/primitives/Primitives/Predicates/Predicates.NullOrEmpty.cs b/src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.NullOrEmpty.cs similarity index 100% rename from src/primitives/Primitives/Predicates/Predicates.NullOrEmpty.cs rename to src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.NullOrEmpty.cs diff --git a/src/primitives/Primitives/Predicates/Predicates.NullOrWhiteSpace.cs b/src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.NullOrWhiteSpace.cs similarity index 100% rename from src/primitives/Primitives/Predicates/Predicates.NullOrWhiteSpace.cs rename to src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.NullOrWhiteSpace.cs diff --git a/src/primitives/Primitives/Predicates/Predicates.cs b/src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.cs similarity index 100% rename from src/primitives/Primitives/Predicates/Predicates.cs rename to src/primitives-predicates/Primitives.Predicates/Predicates/Predicates.cs diff --git a/src/primitives-predicates/Primitives.Predicates/Primitives.Predicates.csproj b/src/primitives-predicates/Primitives.Predicates/Primitives.Predicates.csproj new file mode 100644 index 00000000..61d12655 --- /dev/null +++ b/src/primitives-predicates/Primitives.Predicates/Primitives.Predicates.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + true + true + LICENSE + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack Primitives.Predicates is a core library for .NET consisting of useful extensions and predicates making work with the nullable feature easier. + System + PrimeFuncPack.Primitives.Predicates + 2.0.0-preview.2.0.0 + + + + + True + + + + + diff --git a/src/primitives-strings/Primitives.Strings.Tests/Primitives.Strings.Tests.csproj b/src/primitives-strings/Primitives.Strings.Tests/Primitives.Strings.Tests.csproj new file mode 100644 index 00000000..d88344e7 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Primitives.Strings.Tests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + false + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack.Primitives.Tests + PrimeFuncPack.Primitives.Strings.Tests + + + + + + + + + + + + + + diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrEmpty.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrEmpty.cs new file mode 100644 index 00000000..7734cfe9 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrEmpty.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringExtensionsTests + { + [Test] + public void OrEmpty_SourceIsNull_ExpectEmpty() + { + string? source = null; + + var actual = source.OrEmpty(); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void OrEmpty_SourceIsNotNull_ExpectSourceValue( + string source) + { + var actual = source.OrEmpty(); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfEmpty.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfEmpty.cs new file mode 100644 index 00000000..2da816b3 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfEmpty.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringExtensionsTests + { + [Test] + public void OrNullIfEmpty_SourceIsEmpty_ExpectNull() + { + string? source = string.Empty; + + var actual = source.OrNullIfEmpty(); + Assert.IsNull(actual); + } + + [Test] + [TestCase(null)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void OrNullIfEmpty_SourceIsNotEmpty_ExpectSourceValue( + string? source) + { + var actual = source.OrNullIfEmpty(); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfWhiteSpace.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfWhiteSpace.cs new file mode 100644 index 00000000..f88a26db --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/OrNullIfWhiteSpace.cs @@ -0,0 +1,33 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringExtensionsTests + { + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void OrNullIfWhiteSpace_SourceIsWhiteSpace_ExpectNull( + string? source) + { + var actual = source.OrNullIfWhiteSpace(); + Assert.IsNull(actual); + } + + [Test] + [TestCase(null)] + [TestCase(SomeString)] + public void OrNullIfWhiteSpace_SourceIsNotWhiteSpace_ExpectSourceValue( + string? source) + { + var actual = source.OrNullIfWhiteSpace(); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/Tests.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/Tests.cs new file mode 100644 index 00000000..886e099a --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/Tests.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class StringExtensionsTests + { + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_Ref.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_Ref.cs new file mode 100644 index 00000000..884d7792 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_Ref.cs @@ -0,0 +1,43 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringExtensionsTests + { + [Test] + public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty() + { + ToStringStubRefType? source = null; + + var actual = source.ToStringOrEmpty(); + Assert.IsEmpty(actual); + } + + [Test] + public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty() + { + ToStringStubRefType? source = new(null); + + var actual = source.ToStringOrEmpty(); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void ToStringOrEmpty_Ref_SourceToStringIsNotNull_ExpectActualToStringValue( + string sourceToStringValue) + { + ToStringStubRefType? source = new(sourceToStringValue); + + var actual = source.ToStringOrEmpty(); + Assert.AreEqual(sourceToStringValue, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_StructNullable.cs b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_StructNullable.cs new file mode 100644 index 00000000..64e5a35c --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/StringExtensions.Tests/ToStringOrEmpty_StructNullable.cs @@ -0,0 +1,43 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringExtensionsTests + { + [Test] + public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty() + { + ToStringStubStructType? source = null; + + var actual = source.ToStringOrEmpty(); + Assert.IsEmpty(actual); + } + + [Test] + public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty() + { + ToStringStubStructType? source = new(null); + + var actual = source.ToStringOrEmpty(); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void ToStringOrEmpty_StructNullable_SourceToStringIsNotNull_ExpectActualToStringValue( + string sourceToStringValue) + { + ToStringStubStructType? source = new(sourceToStringValue); + + var actual = source.ToStringOrEmpty(); + Assert.AreEqual(sourceToStringValue, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Empty.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Empty.cs new file mode 100644 index 00000000..e248405c --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Empty.cs @@ -0,0 +1,24 @@ +#nullable enable + +using NUnit.Framework; +using System; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + public void Empty_ExpectEmptyString() + { + var actual = Strings.Empty; + Assert.IsEmpty(actual); + } + + [Test] + public void GetEmpty_ExpectEmptyString() + { + var actual = Strings.GetEmpty(); + Assert.IsEmpty(actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrEmpty.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrEmpty.cs new file mode 100644 index 00000000..7db99e6d --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrEmpty.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + public void OrEmpty_SourceIsNull_ExpectEmpty() + { + string? source = null; + + var actual = Strings.OrEmpty(source); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void OrEmpty_SourceIsNotNull_ExpectSourceValue( + string source) + { + var actual = Strings.OrEmpty(source); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfEmpty.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfEmpty.cs new file mode 100644 index 00000000..95b462cd --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfEmpty.cs @@ -0,0 +1,32 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + public void OrNullIfEmpty_SourceIsEmpty_ExpectNull() + { + string? source = string.Empty; + + var actual = Strings.OrNullIfEmpty(source); + Assert.IsNull(actual); + } + + [Test] + [TestCase(null)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void OrNullIfEmpty_SourceIsNotEmpty_ExpectSourceValue( + string? source) + { + var actual = Strings.OrNullIfEmpty(source); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfWhiteSpace.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfWhiteSpace.cs new file mode 100644 index 00000000..3489ef0c --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/OrNullIfWhiteSpace.cs @@ -0,0 +1,33 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(ThreeWhiteSpacesString)] + [TestCase(TabString)] + public void OrNullIfWhiteSpace_SourceIsWhiteSpace_ExpectNull( + string? source) + { + var actual = Strings.OrNullIfWhiteSpace(source); + Assert.IsNull(actual); + } + + [Test] + [TestCase(null)] + [TestCase(SomeString)] + public void OrNullIfWhiteSpace_SourceIsNotWhiteSpace_ExpectSourceValue( + string? source) + { + var actual = Strings.OrNullIfWhiteSpace(source); + Assert.AreSame(source, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Tests.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Tests.cs new file mode 100644 index 00000000..9645c816 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/Tests.cs @@ -0,0 +1,8 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + public sealed partial class StringsTests + { + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_Ref.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_Ref.cs new file mode 100644 index 00000000..490c1694 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_Ref.cs @@ -0,0 +1,43 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + public void ToStringOrEmpty_Ref_SourceIsNull_ExpectEmpty() + { + ToStringStubRefType? source = null; + + var actual = Strings.ToStringOrEmpty(source); + Assert.IsEmpty(actual); + } + + [Test] + public void ToStringOrEmpty_Ref_SourceToStringIsNull_ExpectEmpty() + { + ToStringStubRefType? source = new(null); + + var actual = Strings.ToStringOrEmpty(source); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void ToStringOrEmpty_Ref_SourceToStringIsNotNull_ExpectActualToStringValue( + string sourceToStringValue) + { + ToStringStubRefType? source = new(sourceToStringValue); + + var actual = Strings.ToStringOrEmpty(source); + Assert.AreEqual(sourceToStringValue, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_StructNullable.cs b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_StructNullable.cs new file mode 100644 index 00000000..6bef6d51 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Strings.Tests/ToStringOrEmpty_StructNullable.cs @@ -0,0 +1,43 @@ +#nullable enable + +using NUnit.Framework; +using System; +using static PrimeFuncPack.UnitTest.TestData; + +namespace PrimeFuncPack.Primitives.Tests +{ + partial class StringsTests + { + [Test] + public void ToStringOrEmpty_StructNullable_SourceIsNull_ExpectEmpty() + { + ToStringStubStructType? source = null; + + var actual = Strings.ToStringOrEmpty(source); + Assert.IsEmpty(actual); + } + + [Test] + public void ToStringOrEmpty_StructNullable_SourceToStringIsNull_ExpectEmpty() + { + ToStringStubStructType? source = new(null); + + var actual = Strings.ToStringOrEmpty(source); + Assert.IsEmpty(actual); + } + + [Test] + [TestCase(EmptyString)] + [TestCase(WhiteSpaceString)] + [TestCase(TabString)] + [TestCase(SomeString)] + public void ToStringOrEmpty_StructNullable_SourceToStringIsNotNull_ExpectActualToStringValue( + string sourceToStringValue) + { + ToStringStubStructType? source = new(sourceToStringValue); + + var actual = Strings.ToStringOrEmpty(source); + Assert.AreEqual(sourceToStringValue, actual); + } + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubRefType.cs b/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubRefType.cs new file mode 100644 index 00000000..653444d8 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubRefType.cs @@ -0,0 +1,15 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + internal sealed class ToStringStubRefType + { + private readonly string? toStringValue; + + public ToStringStubRefType(string? toStringValue) + => this.toStringValue = toStringValue; + + public override string? ToString() + => toStringValue; + } +} diff --git a/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubStructType.cs b/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubStructType.cs new file mode 100644 index 00000000..9a5262ba --- /dev/null +++ b/src/primitives-strings/Primitives.Strings.Tests/Stubs/ToStringStubStructType.cs @@ -0,0 +1,15 @@ +#nullable enable + +namespace PrimeFuncPack.Primitives.Tests +{ + internal readonly struct ToStringStubStructType + { + private readonly string? toStringValue; + + public ToStringStubStructType(string? toStringValue) + => this.toStringValue = toStringValue; + + public override string? ToString() + => toStringValue; + } +} diff --git a/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj b/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj new file mode 100644 index 00000000..ca8ff404 --- /dev/null +++ b/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + disable + enable + true + true + true + LICENSE + Andrei Sergeev, Pavel Moskovoy + Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy + PrimeFuncPack Primitives.Strings is a core library for .NET consisting of useful extensions making work with strings and the nullable feature easier. + System + PrimeFuncPack.Primitives.Strings + 2.0.0-preview.2.0.0 + + + + + True + + + + + diff --git a/src/primitives/Primitives/Strings/StringExtensions.cs b/src/primitives-strings/Primitives.Strings/StringExtensions.cs similarity index 100% rename from src/primitives/Primitives/Strings/StringExtensions.cs rename to src/primitives-strings/Primitives.Strings/StringExtensions.cs diff --git a/src/primitives/Primitives/Strings/Strings.cs b/src/primitives-strings/Primitives.Strings/Strings.cs similarity index 100% rename from src/primitives/Primitives/Strings/Strings.cs rename to src/primitives-strings/Primitives.Strings/Strings.cs diff --git a/src/primitives/Primitives/Pipeline/Pipeline.cs b/src/primitives/Primitives/Pipeline/Pipeline.cs deleted file mode 100644 index 0be89211..00000000 --- a/src/primitives/Primitives/Pipeline/Pipeline.cs +++ /dev/null @@ -1,8 +0,0 @@ -#nullable enable - -namespace System -{ - public static partial class Pipeline - { - } -} diff --git a/src/primitives/Primitives/Pipeline/PipelineExtensions.cs b/src/primitives/Primitives/Pipeline/PipelineExtensions.cs deleted file mode 100644 index 2cc0cb8b..00000000 --- a/src/primitives/Primitives/Pipeline/PipelineExtensions.cs +++ /dev/null @@ -1,8 +0,0 @@ -#nullable enable - -namespace System -{ - public static partial class PipelineExtensions - { - } -} diff --git a/src/primitives/Primitives/Primitives.csproj b/src/primitives/Primitives/Primitives.csproj index 0d09441d..d5286c42 100644 --- a/src/primitives/Primitives/Primitives.csproj +++ b/src/primitives/Primitives/Primitives.csproj @@ -10,10 +10,10 @@ LICENSE Andrei Sergeev, Pavel Moskovoy Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, the nullable feature, etc. easier. + PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, strings, the nullable feature, etc. easier. System PrimeFuncPack.Primitives - 2.0.0-preview.1.0.0 + 2.0.0-preview.2.0.0 @@ -23,4 +23,11 @@ + + + + + + + From ffc42356da53c272fcd7a0afa056ece7311b6d82 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Tue, 21 Sep 2021 07:48:32 +0300 Subject: [PATCH 2/5] Update Description --- .../Primitives.Strings/Primitives.Strings.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj b/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj index ca8ff404..9a353b47 100644 --- a/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj +++ b/src/primitives-strings/Primitives.Strings/Primitives.Strings.csproj @@ -10,7 +10,7 @@ LICENSE Andrei Sergeev, Pavel Moskovoy Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack Primitives.Strings is a core library for .NET consisting of useful extensions making work with strings and the nullable feature easier. + PrimeFuncPack Primitives.Strings is a core library for .NET consisting of useful extensions making work with strings easier. System PrimeFuncPack.Primitives.Strings 2.0.0-preview.2.0.0 From 700f4618d3d5aac85a0cb02e09d2fcc9dbd0491f Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Tue, 21 Sep 2021 08:02:18 +0300 Subject: [PATCH 3/5] Setup dotnet yml --- .github/workflows/dotnet.yml | 74 +++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3903fba6..3873abe2 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -32,6 +32,74 @@ jobs: - name: Add Local Nuget Source run: dotnet nuget add source ~/nuget + # Primitives.Linq + + - name: Restore Primitives.Linq + run: dotnet restore ./src/*/*/Primitives.Linq.csproj + + - name: Build Primitives.Linq + run: dotnet build ./src/*/*/Primitives.Linq.csproj --no-restore -c Release + + - name: Pack Primitives.Linq + run: dotnet pack ./src/*/*/Primitives.Linq.csproj --no-restore -o ~/nuget -c Release + + - name: Restore Primitives.Linq.Tests + run: dotnet restore ./src/*/*/Primitives.Linq.Tests.csproj + + - name: Test Primitives.Linq.Tests + run: dotnet test ./src/*/*/Primitives.Linq.Tests.csproj --no-restore -c Release + + # Primitives.Pipeline + + - name: Restore Primitives.Pipeline + run: dotnet restore ./src/*/*/Primitives.Pipeline.csproj + + - name: Build Primitives.Pipeline + run: dotnet build ./src/*/*/Primitives.Pipeline.csproj --no-restore -c Release + + - name: Pack Primitives.Pipeline + run: dotnet pack ./src/*/*/Primitives.Pipeline.csproj --no-restore -o ~/nuget -c Release + + - name: Restore Primitives.Pipeline.Tests + run: dotnet restore ./src/*/*/Primitives.Pipeline.Tests.csproj + + - name: Test Primitives.Pipeline.Tests + run: dotnet test ./src/*/*/Primitives.Pipeline.Tests.csproj --no-restore -c Release + + # Primitives.Predicates + + - name: Restore Primitives.Predicates + run: dotnet restore ./src/*/*/Primitives.Predicates.csproj + + - name: Build Primitives.Predicates + run: dotnet build ./src/*/*/Primitives.Predicates.csproj --no-restore -c Release + + - name: Pack Primitives.Predicates + run: dotnet pack ./src/*/*/Primitives.Predicates.csproj --no-restore -o ~/nuget -c Release + + - name: Restore Primitives.Predicates.Tests + run: dotnet restore ./src/*/*/Primitives.Predicates.Tests.csproj + + - name: Test Primitives.Predicates.Tests + run: dotnet test ./src/*/*/Primitives.Predicates.Tests.csproj --no-restore -c Release + + # Primitives.Strings + + - name: Restore Primitives.Strings + run: dotnet restore ./src/*/*/Primitives.Strings.csproj + + - name: Build Primitives.Strings + run: dotnet build ./src/*/*/Primitives.Strings.csproj --no-restore -c Release + + - name: Pack Primitives.Strings + run: dotnet pack ./src/*/*/Primitives.Strings.csproj --no-restore -o ~/nuget -c Release + + - name: Restore Primitives.Strings.Tests + run: dotnet restore ./src/*/*/Primitives.Strings.Tests.csproj + + - name: Test Primitives.Strings.Tests + run: dotnet test ./src/*/*/Primitives.Strings.Tests.csproj --no-restore -c Release + # Primitives - name: Restore Primitives @@ -43,12 +111,6 @@ jobs: - name: Pack Primitives run: dotnet pack ./src/*/*/Primitives.csproj --no-restore -o ~/nuget -c Release - - name: Restore Primitives.Tests - run: dotnet restore ./src/*/*/Primitives.Tests.csproj - - - name: Test Primitives.Tests - run: dotnet test ./src/*/*/Primitives.Tests.csproj --no-restore -c Release - # Push - name: Push Packages From edf5a51e4fdb4f0a7e288252471513e8d6347923 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Tue, 21 Sep 2021 08:12:28 +0300 Subject: [PATCH 4/5] Format dotnet yml: clean whitespaces --- .github/workflows/dotnet.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3873abe2..b8b82153 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -3,10 +3,10 @@ name: .NET on: push: branches: [ master, dev, feature/*, fix/*, release/* ] - + pull_request: branches: [ master ] - + release: types: [ published ] branches: [ master ] @@ -23,17 +23,17 @@ jobs: with: dotnet-version: 6.0.x include-prerelease: true - + # Create Local NuGet Source - + - name: Create Local NuGet Directory run: mkdir ~/nuget - name: Add Local Nuget Source run: dotnet nuget add source ~/nuget - + # Primitives.Linq - + - name: Restore Primitives.Linq run: dotnet restore ./src/*/*/Primitives.Linq.csproj @@ -48,9 +48,9 @@ jobs: - name: Test Primitives.Linq.Tests run: dotnet test ./src/*/*/Primitives.Linq.Tests.csproj --no-restore -c Release - + # Primitives.Pipeline - + - name: Restore Primitives.Pipeline run: dotnet restore ./src/*/*/Primitives.Pipeline.csproj @@ -65,9 +65,9 @@ jobs: - name: Test Primitives.Pipeline.Tests run: dotnet test ./src/*/*/Primitives.Pipeline.Tests.csproj --no-restore -c Release - + # Primitives.Predicates - + - name: Restore Primitives.Predicates run: dotnet restore ./src/*/*/Primitives.Predicates.csproj @@ -82,9 +82,9 @@ jobs: - name: Test Primitives.Predicates.Tests run: dotnet test ./src/*/*/Primitives.Predicates.Tests.csproj --no-restore -c Release - + # Primitives.Strings - + - name: Restore Primitives.Strings run: dotnet restore ./src/*/*/Primitives.Strings.csproj @@ -99,9 +99,9 @@ jobs: - name: Test Primitives.Strings.Tests run: dotnet test ./src/*/*/Primitives.Strings.Tests.csproj --no-restore -c Release - + # Primitives - + - name: Restore Primitives run: dotnet restore ./src/*/*/Primitives.csproj @@ -110,7 +110,7 @@ jobs: - name: Pack Primitives run: dotnet pack ./src/*/*/Primitives.csproj --no-restore -o ~/nuget -c Release - + # Push - name: Push Packages From a70a8733d2350c467f9563a9fd35d332faf0fdd8 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Tue, 21 Sep 2021 08:23:59 +0300 Subject: [PATCH 5/5] Update Readme md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20490e39..5bc1168b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # PrimeFuncPack Primitives -PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, the nullable feature, etc. easier. +PrimeFuncPack Primitives is a core library for .NET consisting of useful extensions and predicates making work with functional pipelines, Linq, strings, the nullable feature, etc. easier.