From 95772b30e8d9c2b65bf4637291903222f16660ab Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Sat, 21 Sep 2024 22:17:34 +0400 Subject: [PATCH 1/2] Taggeds v3.0-preview.1: Remove TaggedUnion; Remove Obsoletes; Remove net6.0/net7.0 targets; Update test dependencies --- .github/workflows/dotnet.yml | 19 -- .../Failure.Tests/Failure.Tests.csproj | 15 +- .../Failure/Failure.csproj | 6 +- .../FilterNotNull.cs | 84 ----- .../FilterNotNullOrThrow.cs | 154 --------- .../Tests.cs | 8 - .../GetValueOrAbsent.Dictionary.cs | 54 --- .../GetValueOrAbsent.Pair.cs | 92 ------ ...ValueOrAbsent.ReadOnlyDictionary.Public.cs | 60 ---- .../GetValueOrAbsent.ReadOnlyDictionary.cs | 60 ---- .../Tests.cs | 17 - .../ElementAtOrAbsent.cs | 103 ------ .../FirstOrAbsent.cs | 111 ------- .../GetValueOrAbsent.cs | 58 ---- .../LastOrAbsent.cs | 112 ------- .../SingleOrAbsent.cs | 307 ------------------ .../Tests.cs | 17 - .../Optional.Test/Test.YieldSingleOrEmpty.cs | 33 -- .../Optional.Tests.Old.csproj | 17 +- .../Optional.Tests/Optional.Tests.csproj | 13 +- .../Optional.T.YieldSingleOrEmpty.Obsolete.cs | 12 - .../Optional/Optional.csproj | 6 +- ...bsolete.FilterNotNullOptionalExtensions.cs | 53 --- ...lete.OptionalLinqDictionariesExtensions.cs | 32 -- ...solete.OptionalLinqExtensions.IReadOnly.cs | 119 ------- .../Result.Tests.Old/Result.Tests.Old.csproj | 15 +- .../Result.Tests/Result.Tests.csproj | 13 +- src/core-taggeds-result/Result/Result.csproj | 6 +- .../TaggedUnion.Tests.Old/GlobalUsings.cs | 2 - .../OrInitialize.cs | 47 --- .../OrInitializeAsync.cs | 48 --- .../OrInitializeValueAsync.cs | 48 --- .../Test.cs | 8 - .../TaggedUnion.Static.Test/Equals.cs | 151 --------- .../TaggedUnion.Static.Test/Test.cs | 5 - .../Equality/Equality.Static.cs | 147 --------- .../TaggedUnion.Test/Equality/Equality.cs | 147 --------- .../Equality/EqualityObject.cs | 173 ---------- .../Equality/EqualityOther.cs | 134 -------- .../TaggedUnion.Test/Equality/HashCode.cs | 148 --------- .../TaggedUnion.Test/Equality/Inequality.cs | 130 -------- .../Factory.Constructor.First.cs | 17 - .../Factory.Constructor.Second.cs | 17 - .../Factory.Obsolete/Factory.Default.cs | 15 - .../Factory.DefaultConstructor.cs | 15 - .../Factory.Explicit.First.cs | 17 - .../Factory.Explicit.Second.cs | 17 - .../Factory.Implicit.First.Alt.cs | 17 - .../Factory.Implicit.First.cs | 17 - .../Factory.Implicit.Second.Alt.cs | 17 - .../Factory.Implicit.Second.cs | 17 - .../Factory/Factory.Constructor.First.cs | 42 --- .../Factory/Factory.Constructor.Second.cs | 42 --- .../Factory/Factory.Default.cs | 35 -- .../Factory/Factory.DefaultConstructor.cs | 35 -- .../Factory/Factory.Explicit.First.cs | 42 --- .../Factory/Factory.Explicit.Second.cs | 42 --- .../Factory/Factory.Implicit.First.Alt.cs | 42 --- .../Factory/Factory.Implicit.First.cs | 42 --- .../Factory/Factory.Implicit.Second.Alt.cs | 42 --- .../Factory/Factory.Implicit.Second.cs | 42 --- .../TaggedUnion.Test/Fold/Fold.Other.cs | 72 ---- .../Fold/Fold.OtherFactory.cs | 83 ----- .../TaggedUnion.Test/Fold/Fold.cs | 62 ---- .../TaggedUnion.Test/Fold/FoldAsync.Other.cs | 76 ----- .../Fold/FoldAsync.OtherFactory.cs | 98 ------ .../Fold/FoldAsync.OtherFactoryAsync.cs | 100 ------ .../Fold/FoldValueAsync.Other.cs | 83 ----- .../Fold/FoldValueAsync.OtherFactory.cs | 98 ------ .../Fold/FoldValueAsync.OtherFactoryAsync.cs | 106 ------ .../TaggedUnion.Test/Map/Map.cs | 74 ----- .../TaggedUnion.Test/Map/MapAsync.cs | 75 ----- .../TaggedUnion.Test/Map/MapValueAsync.cs | 81 ----- .../TaggedUnion.Test/MapFirst/MapFirst.cs | 55 ---- .../MapFirst/MapFirstAsync.cs | 58 ---- .../MapFirst/MapFirstValueAsync.cs | 58 ---- .../TaggedUnion.Test/MapSecond/MapSecond.cs | 55 ---- .../MapSecond/MapSecondAsync.cs | 58 ---- .../MapSecond/MapSecondValueAsync.cs | 58 ---- .../TaggedUnion.Test/Or/Or.cs | 47 --- .../TaggedUnion.Test/Or/OrAsync.cs | 48 --- .../TaggedUnion.Test/Or/OrValueAsync.cs | 48 --- .../OrThrow/FirstOrThrow.ExceptionFactory.cs | 53 --- .../TaggedUnion.Test/OrThrow/FirstOrThrow.cs | 37 --- .../OrThrow/SecondOrThrow.ExceptionFactory.cs | 53 --- .../TaggedUnion.Test/OrThrow/SecondOrThrow.cs | 36 -- .../TaggedUnion.Test/TaggedUnionTest.cs | 19 -- .../ToString/ToString.First.cs | 124 ------- .../ToString/ToString.None.cs | 24 -- .../ToString/ToString.Second.cs | 124 ------- .../TaggedUnion.Tests.Old.csproj | 38 --- .../TestData/SomeException.cs | 7 - .../TestData/StubToStringType.cs | 14 - .../TestData/TestDataSource.cs | 41 --- .../Extensions.cs | 48 --- .../Inner.Tag/TaggedUnion.T.Tag.cs | 11 - .../TaggedUnion.T.InnerExceptionFactories.cs | 18 - .../TaggedUnion.T.InnerFold.Async.Value.cs | 82 ----- .../Inner/TaggedUnion.T.InnerFold.Async.cs | 82 ----- .../Inner/TaggedUnion.T.InnerFold.Sync.cs | 62 ---- .../Inner/TaggedUnion.T.InnerMap.cs | 57 ---- .../Inner/TaggedUnion.T.InnerMapFirst.cs | 54 --- .../Inner/TaggedUnion.T.InnerMapSecond.cs | 54 --- .../Inner/TaggedUnion.T.InnerOn.TUnit.cs | 58 ---- .../Inner/TaggedUnion.T.InnerOn.Unit.cs | 58 ---- .../Inner/TaggedUnion.T.InnerOn.cs | 58 ---- .../Inner/TaggedUnion.T.InnerOnFirst.TUnit.cs | 43 --- .../Inner/TaggedUnion.T.InnerOnFirst.Unit.cs | 43 --- .../Inner/TaggedUnion.T.InnerOnFirst.cs | 43 --- .../TaggedUnion.T.InnerOnSecond.TUnit.cs | 43 --- .../Inner/TaggedUnion.T.InnerOnSecond.Unit.cs | 43 --- .../Inner/TaggedUnion.T.InnerOnSecond.cs | 43 --- .../Inner/TaggedUnion.T.InnerOr.cs | 25 -- .../Inner/TaggedUnion.T.InnerOrThrow.First.cs | 11 - .../TaggedUnion.T.InnerOrThrow.Second.cs | 11 - .../Inner/TaggedUnion.T.InnerToString.cs | 20 -- .../TaggedUnion.T.Equality.Equals.Wrap.cs | 23 -- .../TaggedUnion.T.Equality.Equals.cs | 26 -- .../TaggedUnion.T.Equality.GetHashCode.cs | 39 --- ...TaggedUnion.T.EqualityComparer.Equality.cs | 57 ---- .../TaggedUnion.T.EqualityComparer.cs | 57 ---- .../TaggedUnion.T.Factory.Constructor.cs | 12 - .../TaggedUnion.T.Factory.Explicit.cs | 12 - .../TaggedUnion.T.Factory.Implicit.cs | 12 - .../TaggedUnion.T.Fold.Async.Value.cs | 45 --- .../TaggedUnion.T/TaggedUnion.T.Fold.Async.cs | 45 --- .../TaggedUnion.T/TaggedUnion.T.Fold.Sync.cs | 32 -- .../TaggedUnion.T/TaggedUnion.T.Map.cs | 30 -- .../TaggedUnion.T/TaggedUnion.T.MapFirst.cs | 24 -- .../TaggedUnion.T/TaggedUnion.T.MapSecond.cs | 24 -- .../TaggedUnion.T/TaggedUnion.T.On.TUnit.cs | 31 -- .../TaggedUnion.T/TaggedUnion.T.On.Unit.cs | 31 -- .../TaggedUnion.T/TaggedUnion.T.On.cs | 31 -- .../TaggedUnion.T.OnFirst.TUnit.cs | 25 -- .../TaggedUnion.T.OnFirst.Unit.cs | 25 -- .../TaggedUnion.T/TaggedUnion.T.OnFirst.cs | 25 -- .../TaggedUnion.T.OnSecond.TUnit.cs | 25 -- .../TaggedUnion.T.OnSecond.Unit.cs | 25 -- .../TaggedUnion.T/TaggedUnion.T.OnSecond.cs | 25 -- .../TaggedUnion.T/TaggedUnion.T.Or.cs | 24 -- .../TaggedUnion.T.OrThrow.First.cs | 12 - .../TaggedUnion.T.OrThrow.Second.cs | 12 - .../TaggedUnion.T/TaggedUnion.T.ToString.cs | 8 - .../TaggedUnion.T/TaggedUnion.T.cs | 33 -- .../TaggedUnion/TaggedUnion.csproj | 39 --- .../TaggedUnion/TaggedUnion.Equality.cs | 9 - .../TaggedUnion/TaggedUnion/TaggedUnion.cs | 6 - .../Taggeds.Tests.Old.csproj | 15 +- .../Obsolete.Optional.ToTaggedUnion.cs | 31 -- .../Obsolete.Result.ToTaggedUnion.cs | 56 ---- .../Obsolete.TaggedUnion.ToOptional.cs | 42 --- .../Obsolete.TaggedUnion.ToResult.cs | 61 ---- .../Taggeds.Tests/Taggeds.Tests.csproj | 13 +- src/core-taggeds/Taggeds/Taggeds.csproj | 13 +- .../Obsolete.Optional.ToTaggedUnion.cs | 11 - .../Obsolete.Result.ToTaggedUnion.cs | 13 - .../Obsolete.TaggedUnion.ToOptional.cs | 11 - .../Obsolete.TaggedUnion.ToResult.cs | 13 - 158 files changed, 76 insertions(+), 7413 deletions(-) delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNull.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNullOrThrow.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/Tests.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Dictionary.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Pair.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.Public.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/Tests.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/ElementAtOrAbsent.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/FirstOrAbsent.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/GetValueOrAbsent.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/LastOrAbsent.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/SingleOrAbsent.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/Tests.cs delete mode 100644 src/core-taggeds-optional/Optional.Tests.Old/Optional.Test/Test.YieldSingleOrEmpty.cs delete mode 100644 src/core-taggeds-optional/Optional/Optional.T/Optional.T.YieldSingleOrEmpty.Obsolete.cs delete mode 100644 src/core-taggeds-optional/Optional/OptionalExtensions.Obsolete/Obsolete.FilterNotNullOptionalExtensions.cs delete mode 100644 src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqDictionariesExtensions.cs delete mode 100644 src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqExtensions.IReadOnly.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/GlobalUsings.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitialize.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeValueAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/Test.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Equals.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Test.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.Static.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityObject.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityOther.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/HashCode.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Inequality.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Default.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.DefaultConstructor.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.Alt.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.Alt.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Default.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.DefaultConstructor.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.Alt.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.Alt.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.Other.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.OtherFactory.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.Other.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactory.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactoryAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.Other.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactory.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactoryAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/Map.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapValueAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirst.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstValueAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecond.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondValueAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/Or.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrValueAsync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.ExceptionFactory.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.ExceptionFactory.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/TaggedUnionTest.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.None.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Tests.Old.csproj delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/SomeException.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/StubToStringType.cs delete mode 100644 src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/TestDataSource.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T.Extensions.Obsolete/Extensions.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner.Tag/TaggedUnion.T.Tag.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerExceptionFactories.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.Value.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Sync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMap.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapFirst.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapSecond.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOr.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerToString.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.Wrap.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.GetHashCode.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.Equality.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Constructor.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Explicit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Implicit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.Value.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Sync.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Map.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapFirst.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapSecond.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.TUnit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.Unit.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Or.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.First.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.Second.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.ToString.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion.csproj delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.Equality.cs delete mode 100644 src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.cs delete mode 100644 src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Optional.ToTaggedUnion.cs delete mode 100644 src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Result.ToTaggedUnion.cs delete mode 100644 src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToOptional.cs delete mode 100644 src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToResult.cs delete mode 100644 src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Optional.ToTaggedUnion.cs delete mode 100644 src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Result.ToTaggedUnion.cs delete mode 100644 src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToOptional.cs delete mode 100644 src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToResult.cs diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a31201de..cc18ffb6 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -22,8 +22,6 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.x - 7.0.x 8.0.x # Create Local NuGet Source @@ -74,23 +72,6 @@ jobs: - name: Test Optional.Tests run: dotnet test ./src/*/*/Optional.Tests.csproj --no-restore -c Release - # TaggedUnion - - - name: Restore TaggedUnion - run: dotnet restore ./src/*/*/TaggedUnion.csproj - - - name: Build TaggedUnion - run: dotnet build ./src/*/*/TaggedUnion.csproj --no-restore -c Release - - - name: Pack TaggedUnion - run: dotnet pack ./src/*/*/TaggedUnion.csproj --no-restore -o ~/nuget -c Release - - - name: Restore TaggedUnion.Tests.Old - run: dotnet restore ./src/*/*/TaggedUnion.Tests.Old.csproj - - - name: Test TaggedUnion.Tests.Old - run: dotnet test ./src/*/*/TaggedUnion.Tests.Old.csproj --no-restore -c Release - # Result - name: Restore Result diff --git a/src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj b/src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj index f03cbb43..3fe16302 100644 --- a/src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj +++ b/src/core-taggeds-failure/Failure.Tests/Failure.Tests.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,12 +16,15 @@ - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/core-taggeds-failure/Failure/Failure.csproj b/src/core-taggeds-failure/Failure/Failure.csproj index 23aa2f5b..e8922c72 100644 --- a/src/core-taggeds-failure/Failure/Failure.csproj +++ b/src/core-taggeds-failure/Failure/Failure.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -18,7 +18,7 @@ PrimeFuncPack Core.Failure is a core library for .NET consisting of Failure type targeted for use in functional programming. System PrimeFuncPack.Core.Failure - 2.2.0 + 3.0-preview.1 @@ -33,7 +33,7 @@ - + diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNull.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNull.cs deleted file mode 100644 index 4a5c0b03..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNull.cs +++ /dev/null @@ -1,84 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteFilterNotNullOptionalExtensionsTests -{ - [Test] - public void FilterNotNull_Class_SourceValueIsNotNull_ExpectSource() - { - var source = Optional.Present(PlusFifteenIdRefType); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - Assert.That(actual, Is.EqualTo(source)); - } - - [Test] - public void FilterNotNull_Struct_SourceValueIsNotNull_ExpectSource() - { - var source = Optional.Present(PlusFifteen); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - Assert.That(actual.IsPresent, Is.True); - Assert.That(actual.OrThrow(), Is.EqualTo(source.OrThrow()!.Value)); - } - - [Test] - public void FilterNotNull_SourceValueIsNull_ExpectAbsent() - { - var source = Optional.Present(null); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNull_SourceValueIsNotNullRefType_ExpectNotNullableRefTypePresent() - { - var sourceValue = MinusFifteenIdRefType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNull_SourceValueIsNullRefType_ExpectNotNullableRefTypeAbsent() - { - var source = Optional.Present(null); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNull_SourceValueIsNotNullStructType_ExpectNotNullableStructTypePresent() - { - var sourceValue = SomeTextStructType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNull_SourceValueIsNullStructType_ExpectNotNullableStructTypeAbsent() - { - var source = Optional.Present(null); - - var actual = FilterNotNullOptionalExtensions.FilterNotNull(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNullOrThrow.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNullOrThrow.cs deleted file mode 100644 index c963868d..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/FilterNotNullOrThrow.cs +++ /dev/null @@ -1,154 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteFilterNotNullOptionalExtensionsTests -{ - [Test] - public void FilterNotNullOrThrow_SourceValueIsNotNull_ExpectSource() - { - var source = Optional.Present(ZeroIdRefType); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source); - Assert.That(actual, Is.EqualTo(source)); - } - - [Test] - public void FilterNotNullOrThrow_SourceValueIsNull_ExpectInvalidOperationException() - { - var source = Optional.Present(null); - _ = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_ExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = Optional.Present(SomeTextStructType); - - var ex = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, null!)); - Assert.That(ex!.ParamName, Is.EqualTo("exceptionFactory")); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNotNull_ExpectSource() - { - var source = Optional.Present(ZeroIdRefType); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => new SomeException()); - Assert.That(actual, Is.EqualTo(source)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNull_ExpectCreatedException() - { - var source = Optional.Present(null); - var resultException = new SomeException(); - - var ex = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => resultException)); - Assert.That(ex, Is.SameAs(resultException)); - } - - [Test] - public void FilterNotNullOrThrow_SourceValueIsNotNullRefType_ExpectPresentNotNullable() - { - var sourceValue = PlusFifteenIdRefType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNullOrThrow_SourceValueIsNullRefType_ExpectInvalidOperationException() - { - var source = Optional.Present(null); - _ = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_RefTypeExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = Optional.Present(PlusFifteenIdRefType); - - var ex = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, null!)); - Assert.That(ex!.ParamName, Is.EqualTo("exceptionFactory")); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNotNullRefType_ExpectPresentNotNullable() - { - var sourceValue = PlusFifteenIdRefType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => new SomeException()); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNullRefType_ExpectCreatedException() - { - var source = Optional.Present(null); - var createdException = new SomeException(); - - var actualException = Assert.Throws( - () => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => createdException)); - Assert.That(actualException, Is.SameAs(createdException)); - } - - [Test] - public void FilterNotNullOrThrow_SourceValueIsNotNullStructType_ExpectPresentNotNullable() - { - var sourceValue = SomeTextStructType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNullOrThrow_SourceValueIsNullStructType_ExpectInvalidOperationException() - { - var source = Optional.Present(null); - _ = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_StructExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = Optional.Present(null); - - var ex = Assert.Throws(() => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, null!)); - Assert.That(ex!.ParamName, Is.EqualTo("exceptionFactory")); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNotNullStructType_ExpectPresentNotNullable() - { - var sourceValue = NullTextStructType; - var source = Optional.Present(sourceValue); - - var actual = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => new SomeException()); - var expected = Optional.Present(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FilterNotNullOrThrowWithFactory_SourceValueIsNullStructType_ExpectCreatedException() - { - var source = Optional.Present(null); - var createdException = new SomeException(); - - var actualException = Assert.Throws( - () => _ = FilterNotNullOptionalExtensions.FilterNotNullOrThrow(source, () => createdException)); - Assert.That(actualException, Is.SameAs(createdException)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/Tests.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/Tests.cs deleted file mode 100644 index 13e78451..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.FilterNotNullOptionalExtensions.Tests/Tests.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace PrimeFuncPack.Core.Tests; - -[Obsolete("These cases test obsolete class 'FilterNotNullOptionalExtensions'.")] -public sealed partial class ObsoleteFilterNotNullOptionalExtensionsTests -{ -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Dictionary.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Dictionary.cs deleted file mode 100644 index 5d9358fc..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Dictionary.cs +++ /dev/null @@ -1,54 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteOptionalLinqDictionariesExtensionsTests -{ - [Test] - public void GetValueOrAbsent_DictionaryPairsAreNull_ExpectArgumentNullException() - { - IDictionary sourceDictionary = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("pairs")); - - void Test() - => - _ = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, SomeString); - } - - [Test] - public void GetValueOrAbsent_DictionaryPairsPairsTryGetValueReturnsFalse_ExpectAbsent() - { - var sourceDictionary = new StubDictionary - { - [MinusFifteenIdRefType] = One - }; - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, PlusFifteenIdRefType); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void GetValueOrAbsent_DictionaryPairsPairsTryGetValueReturnsTrue_ExpectPresent( - object? expectedValue) - { - var sourceDictionary = new StubDictionary - { - [SomeTextStructType] = new object(), - [NullTextStructType] = expectedValue - }; - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, NullTextStructType); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Pair.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Pair.cs deleted file mode 100644 index 0d1eb710..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.Pair.cs +++ /dev/null @@ -1,92 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteOptionalLinqDictionariesExtensionsTests -{ - [Test] - public void GetValueOrAbsent_PairsAreNull_ExpectArgumentNullException() - { - IEnumerable> sourcePairs = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("pairs")); - - void Test() - => - _ = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourcePairs, PlusFifteen); - } - - [Test] - public void GetValueOrAbsent_PairsDoNotContainKey_ExpectAbsent() - { - var sourcePairs = CreatePairsCollection( - new(MinusFifteen, ZeroIdRefType), - new(Zero, null), - new(int.MaxValue, PlusFifteenIdRefType)); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourcePairs, PlusFifteen); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void GetValueOrAbsent_PairsContainOnlyOneKey_ExpectPresentKeyValue( - object? expectedValue) - { - var sourceKey = "Some Key"; - - var sourcePairs = CreatePairsCollection( - new(null, ZeroIdRefType), - new(SomeString, PlusFifteenIdRefType), - new(TabString, null), - new(sourceKey, expectedValue), - new(SomeString, MinusFifteenIdRefType)); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourcePairs, sourceKey); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [TestCase] - public void GetValueOrAbsent_PairsContainOnlyOneKeyAndKeyIsNull_ExpectPresentKeyValue() - { - var expectedValue = SomeTextStructType; - - var sourcePairs = CreatePairsCollection( - new(PlusFifteenIdRefType, NullTextStructType), - new(null, expectedValue)); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourcePairs, null); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void GetValueOrAbsent_PairsContainMoreThanOneKey_ExpectFirst() - { - var expectedValue1 = NullTextStructType; - var expectedValue2 = SomeTextStructType; - - var sourcePairs = CreatePairsCollection( - new(PlusFifteenIdRefType, NullTextStructType), - new(MinusFifteenIdRefType, SomeTextStructType), - new(PlusFifteenIdRefType, SomeTextStructType)); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourcePairs, PlusFifteenIdRefType); - - var expected1 = Optional.Present(expectedValue1); - var expected2 = Optional.Present(expectedValue2); - - bool equalToAnExpected = actual.Equals(expected1) || actual.Equals(expected2); - Assert.That(equalToAnExpected); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.Public.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.Public.cs deleted file mode 100644 index 5e558dd5..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.Public.cs +++ /dev/null @@ -1,60 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteOptionalLinqDictionariesExtensionsTests -{ - [Test] - public void GetValueOrAbsent_PublicReadOnlyDictionaryPairsAreNull_ExpectArgumentNullException() - { - IReadOnlyDictionary sourceDictionary = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("dictionary")); - - void Test() - => - _ = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, PlusFifteen); - } - - [Test] - public void GetValueOrAbsent_PublicReadOnlyDictionaryPairsTryGetValueReturnsFalse_ExpectAbsent() - { - var source = new Dictionary - { - [PlusFifteen] = PlusFifteenIdRefType - }; - - var sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, MinusFifteen); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void GetValueOrAbsent_PublicReadOnlyDictionaryPairsTryGetValueReturnsTrue_ExpectPresent() - { - var expectedValue = SomeString; - - var source = new Dictionary - { - [One] = string.Empty, - [PlusFifteen] = expectedValue, - [MinusFifteen] = LowerAnotherString, - [Zero] = null - }; - - var sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, PlusFifteen); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.cs deleted file mode 100644 index 96a98e68..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/GetValueOrAbsent.ReadOnlyDictionary.cs +++ /dev/null @@ -1,60 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteOptionalLinqDictionariesExtensionsTests -{ - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsAreNull_ExpectArgumentNullException() - { - IReadOnlyDictionary sourceDictionary = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("pairs")); - - void Test() - => - _ = OptionalLinqDictionariesExtensions.GetValueOrAbsent((IEnumerable>)sourceDictionary, PlusFifteen); - } - - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsTryGetValueReturnsFalse_ExpectAbsent() - { - var source = new Dictionary - { - [PlusFifteen] = PlusFifteenIdRefType - }; - - IEnumerable> sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, MinusFifteen); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsTryGetValueReturnsTrue_ExpectPresent() - { - var expectedValue = SomeString; - - var source = new Dictionary - { - [One] = string.Empty, - [PlusFifteen] = expectedValue, - [MinusFifteen] = LowerAnotherString, - [Zero] = null - }; - - IEnumerable> sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqDictionariesExtensions.GetValueOrAbsent(sourceDictionary, PlusFifteen); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/Tests.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/Tests.cs deleted file mode 100644 index 61194168..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqDictionariesExtensions.Tests/Tests.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PrimeFuncPack.Core.Tests; - -[Obsolete("These cases test obsolete class 'OptionalLinqDictionariesExtensions'.")] -public sealed partial class ObsoleteOptionalLinqDictionariesExtensionsTests -{ - private static IEnumerable> CreatePairsCollection( - params KeyValuePair[] pairs) - { - foreach (var pair in pairs) - { - yield return pair; - } - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/ElementAtOrAbsent.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/ElementAtOrAbsent.cs deleted file mode 100644 index 886c6304..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/ElementAtOrAbsent.cs +++ /dev/null @@ -1,103 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - [Test] - public void ElementAtOrAbsentByInt_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - int index = 1; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - } - - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - [TestCase(3)] - public void ElementAtOrAbsentByInt_ReadOnlyListIndexIsInRange_ExpectPresentItem( - int index) - { - var source = CreateReadOnlyList(null, MinusFifteenIdRefType, ZeroIdRefType, PlusFifteenIdRefType); - var actual = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - - var expectedValue = source.ElementAt(index); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCase(int.MinValue)] - [TestCase(-1)] - [TestCase(2)] - [TestCase(int.MaxValue)] - public void ElementAtOrAbsentByInt_ReadOnlyListIndexIsNotInRange_ExpectAbsent( - int index) - { - var source = CreateReadOnlyList(SomeTextStructType, default); - - var actual = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void ElementAtOrAbsentByLong_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - long index = 1; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - } - - [Test] - [TestCase(0)] - [TestCase(1)] - [TestCase(2)] - public void ElementAtOrAbsentByLong_ReadOnlyListIndexIsInRange_ExpectPresentItem( - int index) - { - var source = CreateReadOnlyList(PlusFifteenIdRefType, null, ZeroIdRefType); - var actual = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - - var expectedValue = source.ElementAt(index); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCase(long.MinValue)] - [TestCase(-1)] - [TestCase(4)] - [TestCase(long.MaxValue)] - public void ElementAtOrAbsentByLong_ReadOnlyListIndexIsNotInRange_ExpectAbsent( - long index) - { - var source = CreateReadOnlyList(PlusFifteenIdRefType, MinusFifteenIdRefType, ZeroIdRefType, null); - - var actual = OptionalLinqExtensions.ElementAtOrAbsent(source, index); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/FirstOrAbsent.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/FirstOrAbsent.cs deleted file mode 100644 index 8ddddd7b..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/FirstOrAbsent.cs +++ /dev/null @@ -1,111 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - [Test] - public void FirstOrAbsent_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.FirstOrAbsent(source); - } - - [Test] - public void FirstOrAbsent_ReadOnlyListSourceIsEmpty_ExpectAbsent() - { - var source = CreateReadOnlyList(); - - var actual = OptionalLinqExtensions.FirstOrAbsent(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void FirstOrAbsent_ReadOnlyListSourceIsNotEmpty_ExpectPresentFirstItem( - object? firstItem) - { - var source = CreateReadOnlyList(firstItem, new object(), new { Value = SomeString }); - - var actual = OptionalLinqExtensions.FirstOrAbsent(source); - var expected = Optional.Present(firstItem); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FirstOrAbsentByPredicate_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.FirstOrAbsent(source, static _ => true); - } - - [Test] - public void FirstOrAbsentByPredicate_ReadOnlyListPredicateIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(SomeTextStructType); - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("predicate")); - - void Test() - => - _ = OptionalLinqExtensions.FirstOrAbsent(source, null!); - } - - [Test] - public void FirstOrAbsentByPredicate_ReadOnlyListPredicateResultIsAlreadyFalse_ExpectAbsent() - { - var source = CreateReadOnlyList(SomeTextStructType, NullTextStructType); - - var actual = OptionalLinqExtensions.FirstOrAbsent(source, static _ => false); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void FirstOrAbsentByPredicate_ReadOnlyListPredicateResultIsNotAlreadyFalse_ExpectPresentFirstSuccessful() - { - const int expectedId = 171; - - var expectedValue = new RefType - { - Id = expectedId - }; - - var otherRefType = new RefType - { - Id = expectedId - }; - - var source = CreateReadOnlyList(PlusFifteenIdRefType, expectedValue, MinusFifteenIdRefType, null, otherRefType); - - var actual = OptionalLinqExtensions.FirstOrAbsent(source, Predicate); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - - static bool Predicate(RefType? item) - => - item?.Id is expectedId; - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/GetValueOrAbsent.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/GetValueOrAbsent.cs deleted file mode 100644 index 29b7035c..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/GetValueOrAbsent.cs +++ /dev/null @@ -1,58 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsAreNull_ExpectArgumentNullException() - { - IReadOnlyDictionary sourceDictionary = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("dictionary")); - - void Test() - => - _ = OptionalLinqExtensions.GetValueOrAbsent(sourceDictionary, PlusFifteen); - } - - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsTryGetValueReturnsFalse_ExpectAbsent() - { - var source = new Dictionary - { - [PlusFifteen] = MinusFifteenIdRefType - }; - - var sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqExtensions.GetValueOrAbsent(sourceDictionary, MinusFifteen); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void GetValueOrAbsent_ReadOnlyDictionaryPairsTryGetValueReturnsTrue_ExpectPresent() - { - var expectedValue = MinusFifteenIdNullNameRecord; - - var source = new Dictionary - { - [decimal.MinusOne] = expectedValue, - [decimal.MaxValue] = PlusFifteenIdSomeStringNameRecord - }; - - var sourceDictionary = new StubReadOnlyDictionary(source); - - var actual = OptionalLinqExtensions.GetValueOrAbsent(sourceDictionary, decimal.MinusOne); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/LastOrAbsent.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/LastOrAbsent.cs deleted file mode 100644 index bd97736c..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/LastOrAbsent.cs +++ /dev/null @@ -1,112 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - [Test] - public void LastOrAbsent_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.LastOrAbsent(source); - } - - [Test] - public void LastOrAbsent_ReadOnlyListSourceIsEmpty_ExpectAbsent() - { - var source = CreateReadOnlyList(); - - var actual = OptionalLinqExtensions.LastOrAbsent(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void LastOrAbsent_ReadOnlyListSourceIsNotEmpty_ExpectPresentLastItem( - object? lastItem) - { - var source = CreateReadOnlyList(new object(), new { Value = SomeString }, lastItem); - - var actual = OptionalLinqExtensions.LastOrAbsent(source); - var expected = Optional.Present(lastItem); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void LastOrAbsentByPredicate_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.LastOrAbsent(source, static _ => true); - } - - [Test] - public void LastOrAbsentByPredicate_ReadOnlyListPredicateIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(SomeTextStructType); - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("predicate")); - - void Test() - => - _ = OptionalLinqExtensions.LastOrAbsent(source, null!); - } - - [Test] - public void LastOrAbsentByPredicate_ReadOnlyListPredicateResultIsAlreadyFalse_ExpectAbsent() - { - var source = CreateReadOnlyList(SomeTextStructType, NullTextStructType); - - var actual = OptionalLinqExtensions.LastOrAbsent(source, static _ => false); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void LastOrAbsentByPredicate_ReadOnlyListPredicateResultIsNotAlreadyFalse_ExpectPresentLastSuccessful() - { - const int expectedId = 255; - - var expectedValue = new RefType - { - Id = expectedId - }; - - var otherRefType = new RefType - { - Id = expectedId - }; - - var source = CreateReadOnlyList( - PlusFifteenIdRefType, otherRefType, MinusFifteenIdRefType, null, expectedValue, ZeroIdRefType); - - var actual = OptionalLinqExtensions.LastOrAbsent(source, Predicate); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - - static bool Predicate(RefType? item) - => - item?.Id is expectedId; - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/SingleOrAbsent.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/SingleOrAbsent.cs deleted file mode 100644 index 4761c2fe..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/SingleOrAbsent.cs +++ /dev/null @@ -1,307 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - [Test] - public void SingleOrAbsent_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source); - } - - [Test] - public void SingleOrAbsent_ReadOnlyListSourceIsEmpty_ExpectAbsent() - { - var source = CreateReadOnlyList(); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void SingleOrAbsent_ReadOnlyListSourceContainsOnlyOneElement_ExpectPresentSingleElement( - object? singleItem) - { - var source = CreateReadOnlyList(singleItem); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source); - var expected = Optional.Present(singleItem); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsent_ReadOnlyListSourceContainsMoreThanOneElement_ExpectInvalidOperationException() - { - var source = CreateReadOnlyList(PlusFifteenIdRefType, MinusFifteenIdRefType); - _ = Assert.Throws(Test); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source); - } - - [Test] - public void SingleOrAbsentWithExceptionFactory_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, CreateSomeException); - } - - [Test] - public void SingleOrAbsentWithExceptionFactory_ReadOnlyListExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(PlusFifteenIdRefType); - Func exceptionFactory = null!; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("moreThanOneElementExceptionFactory")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, exceptionFactory); - } - - [Test] - public void SingleOrAbsentWithExceptionFactory_ReadOnlyListSourceIsEmpty_ExpectAbsent() - { - var source = CreateReadOnlyList(); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, CreateSomeException); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void SingleOrAbsentWithExceptionFactory_ReadOnlyListSourceContainsOnlyOneElement_ExpectPresentSingleElement( - object? singleItem) - { - var source = CreateReadOnlyList(singleItem); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, CreateSomeException); - var expected = Optional.Present(singleItem); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsentWithExceptionFactory_ReadOnlyListSourceContainsMoreThanOneElement_ExpectCreatedException() - { - var source = CreateReadOnlyList(PlusFifteenIdRefType, MinusFifteenIdRefType); - var createdException = new SomeException(); - - var ex = Assert.Throws(Test); - Assert.That(ex, Is.SameAs(createdException)); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, () => createdException); - } - - [Test] - public void SingleOrAbsentByPredicate_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, static _ => false); - } - - [Test] - public void SingleOrAbsentByPredicate_ReadOnlyListPredicateIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(MinusFifteenIdRefType); - Func predicate = null!; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("predicate")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, predicate); - } - - [Test] - public void SingleOrAbsentByPredicate_ReadOnlyListPredicateResultIsAlreadyFalse_ExpectAbsent() - { - var source = CreateReadOnlyList(SomeTextStructType, NullTextStructType); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, static _ => false); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsentByPredicate_ReadOnlyListPredicateResultIsTrueOnlyOnce_ExpectPresentSuccessfulElement() - { - var expectedText = "Expected Text"; - var expectedValue = new StructType - { - Text = expectedText - }; - - var source = CreateReadOnlyList(SomeTextStructType, expectedValue, NullTextStructType, null); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, item => expectedText.Equals(item?.Text, StringComparison.InvariantCultureIgnoreCase)); - var expected = Optional.Present(expectedValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsentByPredicate_ReadOnlyListPredicateResultIsTrueMoreThanOneTime_ExpectInvalidOperationException() - { - const string expectedText = "Expected Text"; - - var expectedValue = new StructType - { - Text = expectedText - }; - - var expectedTextStructType = new StructType - { - Text = expectedText - }; - - var source = CreateReadOnlyList( - SomeTextStructType, expectedValue, NullTextStructType, null, expectedTextStructType); - - _ = Assert.Throws(Test); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, Predicate); - - static bool Predicate(StructType? item) - => - string.Equals(expectedText, item?.Text, StringComparison.InvariantCultureIgnoreCase); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListSourceIsNull_ExpectArgumentNullException() - { - IReadOnlyList source = null!; - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("source")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, static _ => false, CreateSomeException); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListPredicateIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(MinusFifteenIdRefType); - Func predicate = null!; - - var ex = Assert.Throws(Test); - Assert.That(ex!.ParamName, Is.EqualTo("predicate")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, predicate, CreateSomeException); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = CreateReadOnlyList(MinusFifteenIdRefType); - var ex = Assert.Throws(Test); - - Assert.That(ex!.ParamName, Is.EqualTo("moreThanOneMatchExceptionFactory")); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, static _ => false, null!); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListPredicateResultIsAlreadyFalse_ExpectAbsent() - { - var source = CreateReadOnlyList(SomeTextStructType, NullTextStructType); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, static _ => false, CreateSomeException); - var expected = Optional.Absent; - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListPredicateResultIsTrueOnlyOnce_ExpectPresentSuccessfulElement() - { - const string expectedText = "Expected Text"; - var expectedValue = new StructType - { - Text = expectedText - }; - - var source = CreateReadOnlyList(SomeTextStructType, expectedValue, NullTextStructType, null); - - var actual = OptionalLinqExtensions.SingleOrAbsent(source, item => expectedText.Equals(item?.Text, StringComparison.InvariantCultureIgnoreCase), CreateSomeException); - - var expected = Optional.Present(expectedValue); - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void SingleOrAbsentByPredicateAndFactory_ReadOnlyListPredicateResultIsTrueMoreThanOneTime_ExpectCreatedException() - { - const string expectedText = "Expected Text"; - - var expectedValue = new StructType - { - Text = expectedText - }; - - var expectedTextStructType = new StructType - { - Text = expectedText - }; - - var source = CreateReadOnlyList( - SomeTextStructType, expectedValue, NullTextStructType, null, expectedTextStructType); - - var createdException = new SomeException(); - var actualException = Assert.Throws(Test); - - Assert.That(actualException, Is.SameAs(createdException)); - - void Test() - => - _ = OptionalLinqExtensions.SingleOrAbsent(source, Predicate, () => createdException); - - static bool Predicate(StructType? item) - => - string.Equals(expectedText, item?.Text, StringComparison.InvariantCultureIgnoreCase); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/Tests.cs b/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/Tests.cs deleted file mode 100644 index 3f8e38ec..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Obsolete.OptionalLinqExtensions.ReadOnly.Tests/Tests.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PrimeFuncPack.Core.Tests; - -[Obsolete("These cases test obsolete public ReadOnly-based methods of the Optional Linq.")] -public sealed partial class ObsoleteReadOnlyOptionalLinqExtensionsTests -{ - private static IReadOnlyList CreateReadOnlyList( - params T[] items) - => - new StubReadOnlyList(items); - - private static SomeException CreateSomeException() - => - new(); -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Optional.Test/Test.YieldSingleOrEmpty.cs b/src/core-taggeds-optional/Optional.Tests.Old/Optional.Test/Test.YieldSingleOrEmpty.cs deleted file mode 100644 index f7d2a1a1..00000000 --- a/src/core-taggeds-optional/Optional.Tests.Old/Optional.Test/Test.YieldSingleOrEmpty.cs +++ /dev/null @@ -1,33 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Linq; - -namespace PrimeFuncPack.Core.Tests; - -partial class OptionalTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void YieldSingleOrEmpty_SourceIsPresent_ExpectSingleValue( - object? sourceValue) - { - var source = Optional.Present(sourceValue); - var actual = source.YieldSingleOrEmpty(); - - Assert.That(actual.Count(), Is.EqualTo(1)); - - var actualValue = actual.Single(); - Assert.That(actualValue, Is.SameAs(sourceValue)); - } - - [Obsolete] - [Test] - public void YieldSingleOrEmpty_SourceIsAbsent_ExpectEmpty() - { - var source = Optional.Absent; - var actual = source.YieldSingleOrEmpty(); - - Assert.That(actual, Is.Empty); - } -} diff --git a/src/core-taggeds-optional/Optional.Tests.Old/Optional.Tests.Old.csproj b/src/core-taggeds-optional/Optional.Tests.Old/Optional.Tests.Old.csproj index 405cf53f..d9e61d43 100644 --- a/src/core-taggeds-optional/Optional.Tests.Old/Optional.Tests.Old.csproj +++ b/src/core-taggeds-optional/Optional.Tests.Old/Optional.Tests.Old.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,15 +16,18 @@ - - - - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/src/core-taggeds-optional/Optional.Tests/Optional.Tests.csproj b/src/core-taggeds-optional/Optional.Tests/Optional.Tests.csproj index 5f8e73e9..8659e41d 100644 --- a/src/core-taggeds-optional/Optional.Tests/Optional.Tests.csproj +++ b/src/core-taggeds-optional/Optional.Tests/Optional.Tests.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,10 +16,13 @@ - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/core-taggeds-optional/Optional/Optional.T/Optional.T.YieldSingleOrEmpty.Obsolete.cs b/src/core-taggeds-optional/Optional/Optional.T/Optional.T.YieldSingleOrEmpty.Obsolete.cs deleted file mode 100644 index 84a2f3a8..00000000 --- a/src/core-taggeds-optional/Optional/Optional.T/Optional.T.YieldSingleOrEmpty.Obsolete.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; - -namespace System; - -partial struct Optional -{ - // TODO: Remove the method in v3.0 - [Obsolete("This method is obsolete. Call YieldFlattened instead.", error: true)] - public IEnumerable YieldSingleOrEmpty() - => - InnerYieldFlattened(); -} diff --git a/src/core-taggeds-optional/Optional/Optional.csproj b/src/core-taggeds-optional/Optional/Optional.csproj index 5b9295e1..023861a8 100644 --- a/src/core-taggeds-optional/Optional/Optional.csproj +++ b/src/core-taggeds-optional/Optional/Optional.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -18,7 +18,7 @@ PrimeFuncPack Core.Optional is a core library for .NET consisting of Optional monad targeted for use in functional programming. System PrimeFuncPack.Core.Optional - 2.2.0-preview.4 + 3.0-preview.1 @@ -33,7 +33,7 @@ - + \ No newline at end of file diff --git a/src/core-taggeds-optional/Optional/OptionalExtensions.Obsolete/Obsolete.FilterNotNullOptionalExtensions.cs b/src/core-taggeds-optional/Optional/OptionalExtensions.Obsolete/Obsolete.FilterNotNullOptionalExtensions.cs deleted file mode 100644 index b546dd3d..00000000 --- a/src/core-taggeds-optional/Optional/OptionalExtensions.Obsolete/Obsolete.FilterNotNullOptionalExtensions.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace System; - -// TODO: Remove the class in v3.0 -[Obsolete("This class is obsolete. Use FilterNotNull and FilterNotNullOrThrow extension methods instead.", error: true)] -public static partial class FilterNotNullOptionalExtensions -{ - private const string ObsoleteMessage_FilterNotNull - = - "This method is obsolete. Call FilterNotNull extension method instead."; - - private const string ObsoleteMessage_FilterNotNullOrThrow - = - "This method is obsolete. Call FilterNotNullOrThrow extension method instead."; - - [Obsolete(ObsoleteMessage_FilterNotNull, error: true)] - public static Optional FilterNotNull(Optional optional) - => - optional.FilterNotNull(); - - [Obsolete(ObsoleteMessage_FilterNotNull, error: true)] - public static Optional FilterNotNull(Optional optional) - where T : struct - => - optional.FilterNotNull(); - - [Obsolete(ObsoleteMessage_FilterNotNullOrThrow, error: true)] - public static Optional FilterNotNullOrThrow(Optional optional) - => - optional.FilterNotNullOrThrow(); - - [Obsolete(ObsoleteMessage_FilterNotNullOrThrow, error: true)] - public static Optional FilterNotNullOrThrow(Optional optional) - where T : struct - => - optional.FilterNotNullOrThrow(); - - [Obsolete(ObsoleteMessage_FilterNotNullOrThrow, error: true)] - public static Optional FilterNotNullOrThrow(Optional optional, Func exceptionFactory) - { - _ = exceptionFactory ?? throw new ArgumentNullException(nameof(exceptionFactory)); - - return optional.FilterNotNullOrThrow(exceptionFactory); - } - - [Obsolete(ObsoleteMessage_FilterNotNullOrThrow, error: true)] - public static Optional FilterNotNullOrThrow(Optional optional, Func exceptionFactory) - where T : struct - { - _ = exceptionFactory ?? throw new ArgumentNullException(nameof(exceptionFactory)); - - return optional.FilterNotNullOrThrow(exceptionFactory); - } -} diff --git a/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqDictionariesExtensions.cs b/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqDictionariesExtensions.cs deleted file mode 100644 index 0458722b..00000000 --- a/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqDictionariesExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; - -namespace System.Linq; - -// TODO: Remove the class in v3.0 -[Obsolete("This class is obsolete. Use GetValueOrAbsent extension methods instead.", error: true)] -public static class OptionalLinqDictionariesExtensions -{ - private const string ObsoleteMessage_GetValueOrAbsent - = - "This method is obsolete. Call GetValueOrAbsent extension method instead."; - - [Obsolete(ObsoleteMessage_GetValueOrAbsent, error: true)] - public static Optional GetValueOrAbsent( - IReadOnlyDictionary dictionary, - TKey key) - { - _ = dictionary ?? throw new ArgumentNullException(nameof(dictionary)); - - return dictionary.GetValueOrAbsent(key); - } - - [Obsolete(ObsoleteMessage_GetValueOrAbsent, error: true)] - public static Optional GetValueOrAbsent( - IEnumerable> pairs, - TKey key) - { - _ = pairs ?? throw new ArgumentNullException(nameof(pairs)); - - return pairs.GetValueOrAbsent(key); - } -} diff --git a/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqExtensions.IReadOnly.cs b/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqExtensions.IReadOnly.cs deleted file mode 100644 index 660afeaf..00000000 --- a/src/core-taggeds-optional/Optional/OptionalLinqExtensions.Obsolete/Obsolete.OptionalLinqExtensions.IReadOnly.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System.Collections.Generic; - -namespace System.Linq; - -partial class OptionalLinqExtensions -{ - // TODO: Remove the methods in v3.0 - - private const string ObsoleteMessage_IReadOnly - = - "This method is obsolete. Call the IEnumerable-based extension method instead."; - - // ElementAtOrAbsent - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional ElementAtOrAbsent( - IReadOnlyList source, - int index) - => - InnerElementAtOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - index); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional ElementAtOrAbsent( - IReadOnlyList source, - long index) - => - InnerElementAtOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - index); - - // FirstOrAbsent - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional FirstOrAbsent( - IReadOnlyList source) - => - InnerFirstOrAbsent( - source ?? throw new ArgumentNullException(nameof(source))); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional FirstOrAbsent( - IReadOnlyList source, - Func predicate) - => - InnerFirstOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - predicate ?? throw new ArgumentNullException(nameof(predicate))); - - // LastOrAbsent - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional LastOrAbsent( - IReadOnlyList source) - => - InnerLastOrAbsent( - source ?? throw new ArgumentNullException(nameof(source))); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional LastOrAbsent( - IReadOnlyList source, - Func predicate) - => - InnerLastOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - predicate ?? throw new ArgumentNullException(nameof(predicate))); - - // SingleOrAbsent - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional SingleOrAbsent( - IReadOnlyList source) - => - InnerSingleOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - InnerCreateMoreThanOneElementException); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional SingleOrAbsent( - IReadOnlyList source, - Func moreThanOneElementExceptionFactory) - => - InnerSingleOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - moreThanOneElementExceptionFactory ?? throw new ArgumentNullException(nameof(moreThanOneElementExceptionFactory))); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional SingleOrAbsent( - IReadOnlyList source, - Func predicate) - => - InnerSingleOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - predicate ?? throw new ArgumentNullException(nameof(predicate)), - InnerCreateMoreThanOneMatchException); - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional SingleOrAbsent( - IReadOnlyList source, - Func predicate, - Func moreThanOneMatchExceptionFactory) - => - InnerSingleOrAbsent( - source ?? throw new ArgumentNullException(nameof(source)), - predicate ?? throw new ArgumentNullException(nameof(predicate)), - moreThanOneMatchExceptionFactory ?? throw new ArgumentNullException(nameof(moreThanOneMatchExceptionFactory))); - - // GetValueOrAbsent - - [Obsolete(ObsoleteMessage_IReadOnly, error: true)] - public static Optional GetValueOrAbsent( - IReadOnlyDictionary dictionary, - TKey key) - => - InnerGetValueOrAbsent( - dictionary ?? throw new ArgumentNullException(nameof(dictionary)), - key); -} diff --git a/src/core-taggeds-result/Result.Tests.Old/Result.Tests.Old.csproj b/src/core-taggeds-result/Result.Tests.Old/Result.Tests.Old.csproj index 66b587db..f6ab9cc2 100644 --- a/src/core-taggeds-result/Result.Tests.Old/Result.Tests.Old.csproj +++ b/src/core-taggeds-result/Result.Tests.Old/Result.Tests.Old.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,14 +16,17 @@ - - - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/src/core-taggeds-result/Result.Tests/Result.Tests.csproj b/src/core-taggeds-result/Result.Tests/Result.Tests.csproj index 66adf18c..d6a1d207 100644 --- a/src/core-taggeds-result/Result.Tests/Result.Tests.csproj +++ b/src/core-taggeds-result/Result.Tests/Result.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,10 +16,13 @@ - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/core-taggeds-result/Result/Result.csproj b/src/core-taggeds-result/Result/Result.csproj index b975e1d5..461beaf8 100644 --- a/src/core-taggeds-result/Result/Result.csproj +++ b/src/core-taggeds-result/Result/Result.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -18,7 +18,7 @@ PrimeFuncPack Core.Result is a core library for .NET consisting of Result monad targeted for use in functional programming. System PrimeFuncPack.Core.Result - 2.1.0-preview.4 + 3.0-preview.1 @@ -33,7 +33,7 @@ - + diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/GlobalUsings.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/GlobalUsings.cs deleted file mode 100644 index 79c0d7cf..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/GlobalUsings.cs +++ /dev/null @@ -1,2 +0,0 @@ -global using NUnit.Framework; -global using NUnit.Framework.Legacy; \ No newline at end of file diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitialize.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitialize.cs deleted file mode 100644 index 1b543c3e..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitialize.cs +++ /dev/null @@ -1,47 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionExtensionsTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void OrInitialize_OtherFactoryIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws(() => _ = TaggedUnionExtensions.OrInitialize(source, null!)); - ClassicAssert.AreEqual("otherFactory", ex!.ParamName); - } - - [Test] - public void OrInitialize_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(new object()); - var other = TaggedUnion.Second(SomeTextStructType); - - var actual = TaggedUnionExtensions.OrInitialize(source, () => other); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public void OrInitialize_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(ZeroIdRefType); - var other = TaggedUnion.Second(PlusFifteenIdRefType); - - var actual = TaggedUnionExtensions.OrInitialize(source, () => other); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public void OrInitialize_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - var other = TaggedUnion.First(new object()); - - var actual = TaggedUnionExtensions.OrInitialize(source, () => other); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeAsync.cs deleted file mode 100644 index 110892f9..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeAsync.cs +++ /dev/null @@ -1,48 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionExtensionsTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void OrInitializeAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync(async () => _ = await TaggedUnionExtensions.OrInitializeAsync(source, null!)); - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task OrInitializeAsync_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(null); - var other = TaggedUnion.First(ZeroIdRefType); - - var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrInitializeAsync_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(SomeTextStructType); - var other = default(TaggedUnion); - - var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrInitializeAsync_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - var other = TaggedUnion.Second(new RefType()); - - var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other)); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeValueAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeValueAsync.cs deleted file mode 100644 index 1f34ec7c..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/OrInitializeValueAsync.cs +++ /dev/null @@ -1,48 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionExtensionsTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void OrInitializeValueAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync(async () => _ = await TaggedUnionExtensions.OrInitializeValueAsync(source, null!)); - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task OrInitializeValueAsync_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(SomeTextStructType); - var other = default(TaggedUnion); - - var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrInitializeValueAsync_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(default); - var other = TaggedUnion.Second(SomeTextStructType); - - var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrInitializeValueAsync_SourceIsDefault_ExpectOther() - { - var source = new TaggedUnion(); - var other = TaggedUnion.First(MinusFifteenIdRefType); - - var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/Test.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/Test.cs deleted file mode 100644 index b72e7e75..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Extensions.Obsolete.Test/Test.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace PrimeFuncPack.Core.Tests; - -[Obsolete] -public sealed partial class TaggedUnionExtensionsTest -{ -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Equals.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Equals.cs deleted file mode 100644 index 8ce98f12..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Equals.cs +++ /dev/null @@ -1,151 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionStaticTest -{ - [Test] - public void Equals_UnionAIsDefaultAndUnionBIsDefault_ExpectTrue() - { - var unionA = default(TaggedUnion); - var unionB = new TaggedUnion(); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Equals_UnionAFirstValueEqualsUnionBFirstValue_ExpectTrue( - object? sourceValue) - { - var unionA = TaggedUnion.First(sourceValue); - var unionB = TaggedUnion.First(sourceValue); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - public void Equals_UnionASecondValueEqualsUnionBSecondValue_ExpectTrue() - { - var text = "some-text"; - - var aValue = new StructType - { - Text = text - }; - var unionA = TaggedUnion.Second(aValue); - - var bValue = new StructType - { - Text = text - }; - var unionB = (TaggedUnion)bValue; - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - public void Equals_UnionAIsDefaultAndUnionBIsFirst_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.First(null); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAIsDefaultAndUnionBIsSecond_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.Second(default); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAIsFirstAndUnionBIsDefault_ExpectFalse() - { - var unionA = TaggedUnion.First(PlusFifteenIdRefType); - var unionB = default(TaggedUnion); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAIsFirstAndUnionBIsSecond_ExpectFalse() - { - var unionA = TaggedUnion.First(SomeTextStructType); - var unionB = TaggedUnion.Second(SomeTextStructType); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAIsSecondAndUnionBIsDefault_ExpectFalse() - { - var unionA = TaggedUnion.Second(PlusFifteenIdRefType); - var unionB = default(TaggedUnion); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAIsSecondAndUnionBIsFirst_ExpectFalse() - { - var unionA = TaggedUnion.Second(ZeroIdRefType); - var unionB = TaggedUnion.First(ZeroIdRefType); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectFalse() - { - var id = MinusFifteen; - - var aValue = new RefType - { - Id = id - }; - var unionA = TaggedUnion.First(aValue); - - var bValue = new RefType - { - Id = id - }; - var unionB = TaggedUnion.First(bValue); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void Equals_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectFalse() - { - var aValue = new StructType - { - Text = SomeString - }; - var unionA = TaggedUnion.Second(aValue); - - var bValue = new StructType - { - Text = SomeString.ToLower() - }; - var unionB = TaggedUnion.Second(bValue); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Test.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Test.cs deleted file mode 100644 index 06d2d891..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Static.Test/Test.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace PrimeFuncPack.Core.Tests; - -public sealed partial class TaggedUnionStaticTest -{ -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.Static.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.Static.cs deleted file mode 100644 index ffbcf648..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.Static.cs +++ /dev/null @@ -1,147 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void EqualsStatic_UnionAIsDefaultAndUnionBIsDefault_ExpectTrue() - { - var unionA = default(TaggedUnion); - var unionB = new TaggedUnion(); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsStatic_UnionAFirstValueEqualsUnionBFirstValue_ExpectTrue() - { - var aValue = new StructType - { - Text = SomeString - }; - var unionA = TaggedUnion.First(aValue); - - var bValue = new StructType - { - Text = SomeString - }; - var unionB = (TaggedUnion)bValue; - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsStatic_UnionASecondValueEqualsUnionBSecondValue_ExpectTrue() - { - var unionA = TaggedUnion.Second(MinusFifteenIdRefType); - var unionB = (TaggedUnion)MinusFifteenIdRefType; - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsStatic_UnionAIsDefaultAndUnionBIsFirst_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.First(default); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAIsDefaultAndUnionBIsSecond_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.Second(null); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAIsFirstAndUnionBIsDefault_ExpectFalse() - { - var unionA = TaggedUnion.First(SomeTextStructType); - var unionB = default(TaggedUnion); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAIsFirstAndUnionBIsSecond_ExpectFalse() - { - var unionA = TaggedUnion.First(PlusFifteenIdRefType); - var unionB = TaggedUnion.Second(PlusFifteenIdRefType); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAIsSecondAndUnionBIsDefault_ExpectFalse() - { - var unionA = TaggedUnion.Second(PlusFifteenIdRefType); - var unionB = default(TaggedUnion); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAIsSecondAndUnionBIsFirst_ExpectFalse() - { - var unionA = TaggedUnion.Second(SomeTextStructType); - var unionB = TaggedUnion.First(SomeTextStructType); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectFalse() - { - var id = PlusFifteen; - - var aValue = new RefType - { - Id = id - }; - var unionA = TaggedUnion.First(aValue); - - var bValue = new RefType - { - Id = id - }; - var unionB = TaggedUnion.First(bValue); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsStatic_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectFalse() - { - var aValue = new StructType - { - Text = SomeString - }; - var unionA = TaggedUnion.Second(aValue); - - var bValue = new StructType - { - Text = EmptyString - }; - var unionB = TaggedUnion.Second(bValue); - - var actual = TaggedUnion.Equals(unionA, unionB); - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.cs deleted file mode 100644 index d905d451..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Equality.cs +++ /dev/null @@ -1,147 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Equality_UnionAIsDefaultAndUnionBIsDefault_ExpectTrue() - { - var unionA = new TaggedUnion(); - var unionB = default(TaggedUnion); - - var actual = unionA == unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Equality_UnionAFirstValueEqualsUnionBFirstValue_ExpectTrue() - { - var aValue = new StructType - { - Text = SomeString - }; - var unionA = (TaggedUnion)aValue; - - var bValue = new StructType - { - Text = SomeString - }; - var unionB = TaggedUnion.First(bValue); - - var actual = unionA == unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Equality_UnionASecondValueEqualsUnionBSecondValue_ExpectTrue() - { - var unionA = (TaggedUnion)ZeroIdRefType; - var unionB = TaggedUnion.Second(ZeroIdRefType); - - var actual = unionA == unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Equality_UnionAIsDefaultAndUnionBIsFirst_ExpectFalse() - { - var unionA = TaggedUnion.First(default); - var unionB = default(TaggedUnion); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAIsDefaultAndUnionBIsSecond_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.Second(SomeTextStructType); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAIsFirstAndUnionBIsDefault_ExpectFalse() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.First(SomeTextStructType); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAIsFirstAndUnionBIsSecond_ExpectFalse() - { - var unionA = TaggedUnion.First(SomeTextStructType); - var unionB = TaggedUnion.Second(SomeTextStructType); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAIsSecondAndUnionBIsDefault_ExpectFalse() - { - var unionA = TaggedUnion.Second(PlusFifteenIdRefType); - var unionB = default(TaggedUnion); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAIsSecondAndUnionBIsFirst_ExpectFalse() - { - var unionA = TaggedUnion.Second(ZeroIdRefType); - var unionB = TaggedUnion.First(ZeroIdRefType); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectFalse() - { - var id = MinusFifteen; - - var aValue = new RefType - { - Id = id - }; - var unionA = TaggedUnion.First(aValue); - - var bValue = new RefType - { - Id = id - }; - var unionB = TaggedUnion.First(bValue); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Equality_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectFalse() - { - var aValue = new StructType - { - Text = EmptyString - }; - var unionA = TaggedUnion.Second(aValue); - - var bValue = new StructType - { - Text = SomeString - }; - var unionB = TaggedUnion.Second(bValue); - - var actual = unionA == unionB; - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityObject.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityObject.cs deleted file mode 100644 index 79b038d7..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityObject.cs +++ /dev/null @@ -1,173 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void EqualsWithObject_SourceIsDefaultAndObjectIsDefault_ExpectTrue() - { - var source = default(TaggedUnion); - object? obj = new TaggedUnion(); - - var actual = source.Equals(obj); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithObject_SourceFirstValueEqualsObjectFirstValue_ExpectTrue() - { - var source = TaggedUnion.First(null); - object? obj = TaggedUnion.First(null); - - var actual = source.Equals(obj); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithObject_SourceSecondValueEqualsObjectSecondValue_ExpectTrue() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - object? obj = (TaggedUnion)MinusFifteenIdRefType; - - var actual = source.Equals(obj); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithObject_SourceIsDefaultAndObjectIsFirst_ExpectFalse() - { - var source = default(TaggedUnion); - object? obj = TaggedUnion.First(null); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceIsDefaultAndObjectIsSecond_ExpectFalse() - { - var source = default(TaggedUnion); - object? obj = TaggedUnion.Second(PlusFifteenIdRefType); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceIsFirstAndObjectIsDefault_ExpectFalse() - { - var source = TaggedUnion.First(ZeroIdRefType); - object? obj = default(TaggedUnion); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceIsFirstAndObjectIsSecond_ExpectFalse() - { - var source = TaggedUnion.First(null); - object? obj = TaggedUnion.Second(null); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceIsSecondAndObjectIsDefault_ExpectFalse() - { - var source = TaggedUnion.Second(ZeroIdRefType); - object? obj = default(TaggedUnion); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceIsSecondAndObjectIsFirst_ExpectFalse() - { - var source = TaggedUnion.Second(default); - object? obj = TaggedUnion.First(default); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceFirstValueIsNotEqualObjectFirstValue_ExpectFalse() - { - var id = Zero; - - var sourceValue = new RefType - { - Id = id - }; - var source = TaggedUnion.First(sourceValue); - - var objValue = new RefType - { - Id = id - }; - object? obj = TaggedUnion.First(objValue); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_SourceSecondValueIsNotEqualObjectSecondValue_ExpectFalse() - { - var sourceValue = new StructType - { - Text = SomeString - }; - - var source = TaggedUnion.Second(sourceValue); - object? obj = TaggedUnion.Second(null); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_ObjectIsOtherTaggedUnion_ExpectFalse() - { - var sourceValue = new StructType - { - Text = SomeString - }; - - var source = TaggedUnion.Second(sourceValue); - object? obj = TaggedUnion.Second(sourceValue); - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_ObjectIsNotTaggedUnion_ExpectFalse() - { - var sourceValue = PlusFifteenIdRefType; - - var source = TaggedUnion.First(sourceValue); - object? obj = sourceValue; - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithObject_ObjectIsNull_ExpectFalse() - { - var sourceValue = PlusFifteenIdRefType; - - var source = TaggedUnion.First(sourceValue); - object? obj = null; - - var actual = source.Equals(obj); - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityOther.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityOther.cs deleted file mode 100644 index b2c31465..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/EqualityOther.cs +++ /dev/null @@ -1,134 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void EqualsWithOther_SourceIsDefaultAndOtherIsDefault_ExpectTrue() - { - var source = default(TaggedUnion); - var other = new TaggedUnion(); - - var actual = source.Equals(other); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithOther_SourceFirstValueEqualsOtherFirstValue_ExpectTrue() - { - var source = TaggedUnion.First(null); - var other = TaggedUnion.First(null); - - var actual = source.Equals(other); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithOther_SourceSecondValueEqualsOtherSecondValue_ExpectTrue() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - var other = (TaggedUnion)MinusFifteenIdRefType; - - var actual = source.Equals(other); - ClassicAssert.True(actual); - } - - [Test] - public void EqualsWithOther_SourceIsDefaultAndOtherIsFirst_ExpectFalse() - { - var source = default(TaggedUnion); - var other = TaggedUnion.First(null); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceIsDefaultAndOtherIsSecond_ExpectFalse() - { - var source = default(TaggedUnion); - var other = TaggedUnion.Second(PlusFifteenIdRefType); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceIsFirstAndOtherIsDefault_ExpectFalse() - { - var source = TaggedUnion.First(ZeroIdRefType); - var other = default(TaggedUnion); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceIsFirstAndOtherIsSecond_ExpectFalse() - { - var source = TaggedUnion.First(null); - var other = TaggedUnion.Second(null); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceIsSecondAndOtherIsDefault_ExpectFalse() - { - var source = TaggedUnion.Second(ZeroIdRefType); - var other = default(TaggedUnion); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceIsSecondAndOtherIsFirst_ExpectFalse() - { - var source = TaggedUnion.Second(default); - var other = TaggedUnion.First(default); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceFirstValueIsNotEqualOtherFirstValue_ExpectFalse() - { - var id = Zero; - - var sourceValue = new RefType - { - Id = id - }; - var source = TaggedUnion.First(sourceValue); - - var otherValue = new RefType - { - Id = id - }; - var other = TaggedUnion.First(otherValue); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } - - [Test] - public void EqualsWithOther_SourceSecondValueIsNotEqualOtherSecondValue_ExpectFalse() - { - var sourceValue = new StructType - { - Text = SomeString - }; - - var source = TaggedUnion.Second(sourceValue); - var other = TaggedUnion.Second(null); - - var actual = source.Equals(other); - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/HashCode.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/HashCode.cs deleted file mode 100644 index a6598232..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/HashCode.cs +++ /dev/null @@ -1,148 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void GetHashCode_SourceAndOtherAreDefault_ExpectValuesAreEqual() - { - var source = default(TaggedUnion); - var other = new TaggedUnion(); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreEqual(sourceHashCode, otherHashCode); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void GetHashCode_SourceFirstValueIsSameAsOtherFirstValue_ExpectValuesAreEqual( - object? sourceValue) - { - var source = TaggedUnion.First(sourceValue); - var other = TaggedUnion.First(sourceValue); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreEqual(sourceHashCode, otherHashCode); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void GetHashCode_SourceSecondValueIsSameAsOtherSecondValue_ExpectValuesAreEqual( - object? sourceValue) - { - var source = TaggedUnion.Second(sourceValue); - var other = TaggedUnion.Second(sourceValue!); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceIsDefaultAndOtherIsNotDefault_ExpectValuesAreNotEqual() - { - var source = default(TaggedUnion); - var other = TaggedUnion.First(null); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void GetHashCode_SourceFirstValueIsSameAsOtherSecondValue_ExpectValuesAreNotEqual( - object? sourceValue) - { - var source = TaggedUnion.First(sourceValue); - var other = TaggedUnion.Second(sourceValue); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceFirstValueAreNotEqualOtherFirstValue_ExpectValuesAreNotEqual() - { - var source = TaggedUnion.First(new object()); - var other = TaggedUnion.First(new object()); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceSecondValueIsNotSameAsOtherSecondValue_ExpectValuesAreNotEqual() - { - var id = PlusFifteen; - var sourceValue = new RefType - { - Id = id - }; - var source = TaggedUnion.Second(sourceValue); - - var otherValue = new RefType - { - Id = id - }; - var other = TaggedUnion.Second(otherValue); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceFirstValueIsSameAsOtherFirstButSecondTypesAreNotEqual_ExpectValuesAreNotEqual() - { - var sourceValue = MinusFifteenIdRefType; - - var source = TaggedUnion.First(sourceValue); - var other = TaggedUnion.First(sourceValue); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceSecondValueIsSameAsOtherSecondButFirstTypesAreNotEquals_ExpectValuesAreNotEqual() - { - var sourceValue = SomeTextStructType; - - var source = TaggedUnion.Second(sourceValue); - var other = TaggedUnion.Second(sourceValue); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } - - [Test] - public void GetHashCode_SourceAndOtherAreDefaultButTypesAreNotEqual_ExpectValuesAreNotEqual() - { - var source = default(TaggedUnion); - var other = default(TaggedUnion); - - var sourceHashCode = source.GetHashCode(); - var otherHashCode = other.GetHashCode(); - - ClassicAssert.AreNotEqual(sourceHashCode, otherHashCode); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Inequality.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Inequality.cs deleted file mode 100644 index 51afb32a..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Equality/Inequality.cs +++ /dev/null @@ -1,130 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Inequality_UnionAIsDefaultAndUnionBIsFirst_ExpectTrue() - { - var unionA = TaggedUnion.First(ZeroIdRefType); - var unionB = default(TaggedUnion); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAIsDefaultAndUnionBIsSecond_ExpectTrue() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.Second(null); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAIsFirstAndUnionBIsDefault_ExpectTrue() - { - var unionA = default(TaggedUnion); - var unionB = TaggedUnion.First(default); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAIsFirstAndUnionBIsSecond_ExpectTrue() - { - var unionA = TaggedUnion.First(SomeTextStructType); - var unionB = TaggedUnion.Second(SomeTextStructType); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAIsSecondAndUnionBIsDefault_ExpectTrue() - { - var unionA = TaggedUnion.Second(SomeTextStructType); - var unionB = default(TaggedUnion); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAIsSecondAndUnionBIsFirst_ExpectTrue() - { - var unionA = TaggedUnion.Second(null); - var unionB = TaggedUnion.First(null); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectTrue() - { - var aValue = new object(); - var unionA = TaggedUnion.First(aValue); - - var bValue = new object(); - var unionB = TaggedUnion.First(bValue); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void Inequality_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectTrue() - { - var unionA = TaggedUnion.Second(null); - var unionB = TaggedUnion.Second(SomeTextStructType); - - var actual = unionA != unionB; - ClassicAssert.True(actual); - } - - [Test] - public void InInequality_UnionAIsDefaultAndUnionBIsDefault_ExpectFalse() - { - var unionA = new TaggedUnion(); - var unionB = default(TaggedUnion); - - var actual = unionA != unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Inequality_UnionAFirstValueEqualsUnionBFirstValue_ExpectFalse() - { - var aValue = new StructType - { - Text = SomeString - }; - var unionA = (TaggedUnion)aValue; - - var bValue = new StructType - { - Text = SomeString - }; - var unionB = TaggedUnion.First(bValue); - - var actual = unionA != unionB; - ClassicAssert.False(actual); - } - - [Test] - public void Inequality_UnionASecondValueEqualsUnionBSecondValue_ExpectFalse() - { - var unionA = (TaggedUnion)MinusFifteenIdRefType; - var unionB = TaggedUnion.Second(MinusFifteenIdRefType); - - var actual = unionA != unionB; - ClassicAssert.False(actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.First.cs deleted file mode 100644 index a184748f..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.First.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Constructor_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.Second.cs deleted file mode 100644 index 236b9f24..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Constructor.Second.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Default.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Default.cs deleted file mode 100644 index c39ba374..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Default.cs +++ /dev/null @@ -1,15 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - public void Default_ExpectIsInitializedGetsFalse() - { - var taggedUnion = default(TaggedUnion); - ClassicAssert.False(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.DefaultConstructor.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.DefaultConstructor.cs deleted file mode 100644 index 67f68434..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.DefaultConstructor.cs +++ /dev/null @@ -1,15 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - public void DefaultConstructor_ExpectIsInitializedGetsFalse() - { - var taggedUnion = new TaggedUnion(); - ClassicAssert.False(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.First.cs deleted file mode 100644 index 8f468ff1..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.First.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Explicit_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.First(sourceValue); - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.Second.cs deleted file mode 100644 index c813771d..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Explicit.Second.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Explicit_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.Second(sourceValue); - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.Alt.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.Alt.cs deleted file mode 100644 index 525aa8b5..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.Alt.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_Alt_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.cs deleted file mode 100644 index 6a19f163..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.First.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.Alt.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.Alt.cs deleted file mode 100644 index 66b5172c..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.Alt.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_Alt_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.cs deleted file mode 100644 index 92d26748..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory.Obsolete/Factory.Implicit.Second.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_ExpectIsInitializedGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsInitialized); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.First.cs deleted file mode 100644 index cc951d83..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.First.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Constructor_ExpectIsFirstGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsFirst); - } - - [Test] - public void First_Constructor_ExpectIsSecondGetsFalse() - { - var taggedUnion = new TaggedUnion(SomeTextStructType); - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Constructor_ExpectIsNoneGetsFalse( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Constructor_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.Second.cs deleted file mode 100644 index c4914a8c..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Constructor.Second.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Second_ExpectIsFirstGetsFalse() - { - var taggedUnion = new TaggedUnion(PlusFifteenIdRefType); - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_ExpectIsSecondGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_ExpectIsNoneGetsFalse( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - var taggedUnion = new TaggedUnion(sourceValue); - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Default.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Default.cs deleted file mode 100644 index 9c3d3b42..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Default.cs +++ /dev/null @@ -1,35 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Default_ExpectIsFirstGetsFalse() - { - var taggedUnion = default(TaggedUnion); - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - public void Default_ExpectIsSecondGetsFalse() - { - var taggedUnion = default(TaggedUnion); - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - public void Default_ExpectIsNoneGetsTrue() - { - var taggedUnion = default(TaggedUnion); - ClassicAssert.True(taggedUnion.IsNone); - } - - [Test] - public void Default_ExpectIsNotNoneGetsFalse() - { - var taggedUnion = default(TaggedUnion); - ClassicAssert.False(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.DefaultConstructor.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.DefaultConstructor.cs deleted file mode 100644 index 62b4996b..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.DefaultConstructor.cs +++ /dev/null @@ -1,35 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void DefaultConstructor_ExpectIsFirstGetsFalse() - { - var taggedUnion = new TaggedUnion(); - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - public void DefaultConstructor_ExpectIsSecondGetsFalse() - { - var taggedUnion = new TaggedUnion(); - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - public void DefaultConstructor_ExpectIsNoneGetsTrue() - { - var taggedUnion = new TaggedUnion(); - ClassicAssert.True(taggedUnion.IsNone); - } - - [Test] - public void DefaultConstructor_ExpectIsNotNoneGetsFalse() - { - var taggedUnion = new TaggedUnion(); - ClassicAssert.False(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.First.cs deleted file mode 100644 index 21833e24..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.First.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Explicit_ExpectIsFirstGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.First(sourceValue); - ClassicAssert.True(taggedUnion.IsFirst); - } - - [Test] - public void First_Explicit_ExpectIsSecondGetsFalse() - { - var taggedUnion = TaggedUnion.First(SomeTextStructType); - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Explicit_ExpectIsNoneGetsFalse( - object? sourceValue) - { - var taggedUnion = TaggedUnion.First(sourceValue); - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Explicit_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.First(sourceValue); - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.Second.cs deleted file mode 100644 index 056b6f8e..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Explicit.Second.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Second_Explicit_ExpectIsFirstGetsFalse() - { - var taggedUnion = TaggedUnion.Second(PlusFifteenIdRefType); - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Explicit_ExpectIsSecondGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.Second(sourceValue); - ClassicAssert.True(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Explicit_ExpectIsNoneGetsFalse( - object? sourceValue) - { - var taggedUnion = TaggedUnion.Second(sourceValue); - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Explicit_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - var taggedUnion = TaggedUnion.Second(sourceValue); - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.Alt.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.Alt.cs deleted file mode 100644 index 07c6e982..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.Alt.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_Alt_ExpectIsFirstGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsFirst); - } - - [Test] - public void First_Implicit_Alt_ExpectIsSecondGetsFalse() - { - TaggedUnion taggedUnion = MinusFifteenIdRefType; - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_Alt_ExpectIsNoneGetsFalse( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_Alt_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.cs deleted file mode 100644 index c30793a1..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.First.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_ExpectIsFirstGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsFirst); - } - - [Test] - public void First_Implicit_ExpectIsSecondGetsFalse() - { - TaggedUnion taggedUnion = SomeTextStructType; - ClassicAssert.False(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_ExpectIsNoneGetsFalse( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void First_Implicit_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.Alt.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.Alt.cs deleted file mode 100644 index e40b08f2..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.Alt.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Second_Implicit_Alt_ExpectIsFirstGetsFalse() - { - TaggedUnion taggedUnion = ZeroIdRefType; - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_Alt_ExpectIsSecondGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_Alt_ExpectIsNoneGetsFalse( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_Alt_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.cs deleted file mode 100644 index a083b166..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Factory/Factory.Implicit.Second.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Second_Implicit_ExpectIsFirstGetsFalse() - { - TaggedUnion taggedUnion = PlusFifteenIdRefType; - ClassicAssert.False(taggedUnion.IsFirst); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_ExpectIsSecondGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsSecond); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_ExpectIsNoneGetsFalse( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.False(taggedUnion.IsNone); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Second_Implicit_ExpectIsNotNoneGetsTrue( - object? sourceValue) - { - TaggedUnion taggedUnion = sourceValue; - ClassicAssert.True(taggedUnion.IsNotNone); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.Other.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.Other.cs deleted file mode 100644 index 7ed1f8a6..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.Other.cs +++ /dev/null @@ -1,72 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldWithOther_MapFirstIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var second = int.MinValue; - var other = int.MaxValue; - - var ex = Assert.Throws(() => _ = source.Fold(null!, _ => second, other)); - ClassicAssert.AreEqual("mapFirst", ex!.ParamName); - } - - [Test] - public void FoldWithOther_MapSecondIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var first = SomeString; - var other = TabString; - - var ex = Assert.Throws(() => _ = source.Fold(_ => first, null!, other)); - ClassicAssert.AreEqual("mapSecond", ex!.ParamName); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void FoldWithOther_SourceIsDefault_ExpectOther( - object? other) - { - var source = default(TaggedUnion); - - var first = new object(); - var second = new { Id = 251 }; - - var actual = source.Fold(_ => first, _ => second, other); - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public void FoldWithOther_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(new object()); - - var first = MinusFifteenIdRefType; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = source.Fold(_ => first, _ => second, other); - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public void FoldWithOther_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(SomeTextStructType); - - var first = new object(); - object? second = null; - var other = PlusFifteenIdRefType; - - var actual = source.Fold(_ => first, _ => second, other); - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.OtherFactory.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.OtherFactory.cs deleted file mode 100644 index 93d8a54b..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.OtherFactory.cs +++ /dev/null @@ -1,83 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldWithOtherFactory_MapFirstIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = PlusFifteenIdRefType; - var other = MinusFifteenIdRefType; - - var ex = Assert.Throws(() => _ = source.Fold(null!, _ => second, () => other)); - ClassicAssert.AreEqual("mapFirst", ex!.ParamName); - } - - [Test] - public void FoldWithOtherFactory_MapSecondIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var first = new object(); - var other = new object(); - - var ex = Assert.Throws(() => _ = source.Fold(_ => first, null!, () => other)); - ClassicAssert.AreEqual("mapSecond", ex!.ParamName); - } - - [Test] - public void FoldWithOtherFactory_OtherFactoryIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = decimal.MinValue; - var second = decimal.MaxValue; - - var ex = Assert.Throws(() => _ = source.Fold(_ => first, _ => second, null!)); - ClassicAssert.AreEqual("otherFactory", ex!.ParamName); - } - - [Test] - public void FoldWithOtherFactory_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - var first = new object(); - var second = new { Id = 251 }; - var other = new { Id = 515 }; - - var actual = source.Fold(_ => first, _ => second, () => other); - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public void FoldWithOtherFactory_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(null); - - int? first = null; - var second = Zero; - var other = int.MinValue; - - var actual = source.Fold(_ => first, _ => second, () => other); - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public void FoldWithOtherFactory_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(new object()); - - var first = ZeroIdRefType; - var second = MinusFifteenIdRefType; - var other = PlusFifteenIdRefType; - - var actual = source.Fold(_ => first, _ => second, () => other); - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.cs deleted file mode 100644 index 7684f231..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/Fold.cs +++ /dev/null @@ -1,62 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void Fold_MapFirstIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var ex = Assert.Throws(() => _ = source.Fold(null!, _ => new object())); - ClassicAssert.AreEqual("mapFirst", ex!.ParamName); - } - - [Test] - public void Fold_MapSecondIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var ex = Assert.Throws(() => _ = source.Fold(_ => new object(), null!)); - ClassicAssert.AreEqual("mapSecond", ex!.ParamName); - } - - [Test] - public void Fold_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var first = PlusFifteenIdRefType; - var second = MinusFifteenIdRefType; - - var actual = source.Fold(_ => first, _ => second); - ClassicAssert.IsNull(actual); - } - - [Test] - public void Fold_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(MinusFifteenIdRefType); - - var first = SomeTextStructType; - var second = NullTextStructType; - - var actual = source.Fold(_ => first, _ => second); - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public void Fold_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(SomeTextStructType); - - var first = PlusFifteenIdRefType; - var second = ZeroIdRefType; - - var actual = source.Fold(_ => first, _ => second); - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.Other.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.Other.cs deleted file mode 100644 index add1eca7..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.Other.cs +++ /dev/null @@ -1,76 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldAsyncWithOther_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = int.MinValue; - var other = int.MaxValue; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync(null!, _ => Task.FromResult(second), other)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldAsyncWithOther_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(default); - - var first = new object(); - var other = new object(); - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync(_ => Task.FromResult(first), null!, other)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task FoldAsyncWithOther_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - object first = PlusFifteen; - object second = Zero; - object other = SomeString; - - var actual = await source.FoldAsync(_ => Task.FromResult(first), _ => Task.FromResult(second), other); - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldAsyncWithOther_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(default); - - RefType first = null!; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldAsync(_ => Task.FromResult(first), _ => Task.FromResult(second), other); - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public async Task FoldAsyncWithOther_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(PlusFifteenIdRefType); - - StructType? first = SomeTextStructType; - StructType? second = NullTextStructType; - StructType? other = null; - - var actual = await source.FoldAsync(_ => Task.FromResult(first), _ => Task.FromResult(second), other); - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactory.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactory.cs deleted file mode 100644 index 0eea1a68..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactory.cs +++ /dev/null @@ -1,98 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldAsyncWithOtherFactory_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = new { Text = SomeString }; - var other = new { Text = EmptyString }; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync(null!, _ => Task.FromResult(second), () => other)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldAsyncWithOtherFactory_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(null); - - var first = PlusFifteenIdRefType; - var other = ZeroIdRefType; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync(_ => Task.FromResult(first), null!, () => other)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public void FoldAsyncWithOtherFactory_OtherFactoryIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(null); - - var first = PlusFifteenIdRefType; - var second = ZeroIdRefType; - Func otherFactory = null!; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), otherFactory)); - - ClassicAssert.AreEqual("otherFactory", ex!.ParamName); - } - - [Test] - public async Task FoldAsyncWithOtherFactory_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - object first = PlusFifteen; - object second = Zero; - var other = new object(); - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => other); - - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldAsyncWithOtherFactory_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = MinusFifteenIdRefType; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => other); - - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public async Task FoldAsyncWithOtherFactory_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - - var first = SomeTextStructType; - var second = NullTextStructType; - var other = new StructType { Text = "other-text" }; - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => other); - - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactoryAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactoryAsync.cs deleted file mode 100644 index f14b7e38..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldAsync.OtherFactoryAsync.cs +++ /dev/null @@ -1,100 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldAsyncWithOtherFactoryAsync_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(new object()); - - var second = new { Id = 55 }; - var other = new { Id = 35 }; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync( - null!, _ => Task.FromResult(second), () => Task.FromResult(other))); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldAsyncWithOtherFactoryAsync_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = PlusFifteenIdRefType; - var other = ZeroIdRefType; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync( - _ => Task.FromResult(first), null!, () => Task.FromResult(other))); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public void FoldAsyncWithOtherFactoryAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(MinusFifteenIdRefType); - - var first = SomeTextStructType; - var second = NullTextStructType; - Func> otherFactoryAsync = null!; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), otherFactoryAsync)); - - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task FoldAsyncWithOtherFactoryAsync_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - var first = PlusFifteen; - var second = Zero; - var other = MinusFifteen; - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => Task.FromResult(other)); - - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldAsyncWithOtherFactoryAsync_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = MinusFifteenIdRefType; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => Task.FromResult(other)); - - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public async Task FoldAsyncWithOtherFactoryAsync_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - - var first = SomeTextStructType; - var second = new StructType { Text = "second" }; - var other = new StructType { Text = "other" }; - - var actual = await source.FoldAsync( - _ => Task.FromResult(first), _ => Task.FromResult(second), () => Task.FromResult(other)); - - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.Other.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.Other.cs deleted file mode 100644 index 25e0cc54..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.Other.cs +++ /dev/null @@ -1,83 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldValueAsyncWithOther_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = 153; - var other = -201; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync(null!, _ => ValueTask.FromResult(second), other)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldValueAsyncWithOther_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(PlusFifteenIdRefType); - - var first = new object(); - var other = new object(); - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync(_ => ValueTask.FromResult(first), null!, other)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task FoldValueAsyncWithOther_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - var first = new object(); - var second = new object(); - var other = new { Name = "Some Name" }; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), other); - - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldValueAsyncWithOther_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldValueAsync( - static _ => default(ValueTask), _ => ValueTask.FromResult(second), other); - - ClassicAssert.IsNull(actual); - } - - [Test] - public async Task FoldValueAsyncWithOther_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(PlusFifteenIdRefType); - - StructType? first = SomeTextStructType; - StructType? second = NullTextStructType; - StructType? other = null; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), - _ => ValueTask.FromResult(second), - other); - - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactory.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactory.cs deleted file mode 100644 index 52d60495..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactory.cs +++ /dev/null @@ -1,98 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldValueAsyncWithOtherFactory_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = new { Text = SomeString }; - var other = new { Text = EmptyString }; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync(null!, _ => ValueTask.FromResult(second), () => other)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldValueAsyncWithOtherFactory_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(null); - - var first = PlusFifteenIdRefType; - var other = ZeroIdRefType; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync(_ => ValueTask.FromResult(first), null!, () => other)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public void FoldValueAsyncWithOtherFactory_OtherFactoryIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeString); - - var first = PlusFifteenIdRefType; - var second = ZeroIdRefType; - Func otherFactory = null!; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), otherFactory)); - - ClassicAssert.AreEqual("otherFactory", ex!.ParamName); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactory_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - var first = "first value"; - var second = "second value"; - var other = "other value"; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), () => other); - - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactory_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = MinusFifteenIdRefType; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), () => other); - - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactory_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(null); - - var first = new StructType { Text = "first" }; - var second = new StructType { Text = "second" }; - var other = new StructType { Text = "other" }; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), () => other); - - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactoryAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactoryAsync.cs deleted file mode 100644 index 15ae2e71..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Fold/FoldValueAsync.OtherFactoryAsync.cs +++ /dev/null @@ -1,106 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FoldValueAsyncWithOtherFactoryAsync_MapFirstAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var second = new { Id = 211 }; - var other = new { Id = -75 }; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync( - null!, _ => ValueTask.FromResult(second), () => ValueTask.FromResult(other))); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public void FoldValueAsyncWithOtherFactoryAsync_MapSecondAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(MinusFifteenIdRefType); - - var first = new object(); - var other = new { Name = "Some Name" }; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), null!, () => ValueTask.FromResult(other))); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public void FoldValueAsyncWithOtherFactoryAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(new { Id = 211 }); - - var first = SomeTextStructType; - var second = NullTextStructType; - Func> otherFactoryAsync = null!; - - var ex = Assert.ThrowsAsync( - async () => _ = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), _ => ValueTask.FromResult(second), otherFactoryAsync)); - - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactoryAsync_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - - var first = PlusFifteen; - var second = Zero; - var other = 355; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), - _ => ValueTask.FromResult(second), - () => ValueTask.FromResult(other)); - - ClassicAssert.AreEqual(other, actual); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactoryAsync_SourceIsFirst_ExpectFirstResult() - { - var source = TaggedUnion.First(SomeTextStructType); - - var first = MinusFifteenIdRefType; - var second = ZeroIdRefType; - var other = PlusFifteenIdRefType; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), - _ => ValueTask.FromResult(second), - () => ValueTask.FromResult(other)); - - ClassicAssert.AreEqual(first, actual); - } - - [Test] - public async Task FoldValueAsyncWithOtherFactoryAsync_SourceIsSecond_ExpectSecondResult() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - - var first = SomeTextStructType; - var second = new StructType { Text = "second" }; - var other = new StructType { Text = "other" }; - - var actual = await source.FoldValueAsync( - _ => ValueTask.FromResult(first), - _ => ValueTask.FromResult(second), - () => ValueTask.FromResult(other)); - - ClassicAssert.AreEqual(second, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/Map.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/Map.cs deleted file mode 100644 index f04ecb39..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/Map.cs +++ /dev/null @@ -1,74 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void Map_MapFirstFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws( - () => _ = source.Map(null!, _ => SomeTextStructType)); - - ClassicAssert.AreEqual("mapFirst", ex!.ParamName); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void Map_MapSecondFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws( - () => _ = source.Map(_ => 275, null!)); - - ClassicAssert.AreEqual("mapSecond", ex!.ParamName); - } - - [Test] - public void Map_SourceIsFirst_ExpectMapppedValueFirstUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.First(sourceValue); - - var mappedFirst = MinusFifteenIdRefType; - var mappedSecond = EmptyString; - - var actual = source.Map(_ => mappedFirst, _ => mappedSecond); - - var expected = TaggedUnion.First(mappedFirst); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void Map_SourceIsSecond_ExpectMappedValueSecondUnion() - { - var sourceValue = new object(); - var source = TaggedUnion.Second(sourceValue); - - var mappedFirst = SomeString; - var mappedSecond = ZeroIdRefType; - - var actual = source.Map(_ => mappedFirst, _ => mappedSecond); - - var expected = TaggedUnion.Second(mappedSecond); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void Map_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedFirst = SomeTextStructType; - var mappedSecond = int.MaxValue; - - var actual = source.Map(_ => mappedFirst, _ => mappedSecond); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapAsync.cs deleted file mode 100644 index d78dc6ec..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapAsync.cs +++ /dev/null @@ -1,75 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapAsync_MapFirstAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapAsync(null!, _ => Task.FromResult(SomeString))); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapAsync_MapSecondAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapAsync(_ => Task.FromResult(21.5m), null!)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task MapAsync_SourceIsFirst_ExpectMapppedValueFirstUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.First(sourceValue); - - RefType mappedFirst = null!; - var mappedSecond = SomeString; - - var actual = await source.MapAsync(_ => Task.FromResult(mappedFirst), _ => Task.FromResult(mappedSecond)); - - var expected = TaggedUnion.First(mappedFirst); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapAsync_SourceIsSecond_ExpectMappedValueSecondUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.Second(sourceValue); - - var mappedFirst = MinusFifteenIdRefType; - object mappedSecond = new { Name = "Some Name" }; - - var actual = await source.MapAsync(_ => Task.FromResult(mappedFirst), _ => Task.FromResult(mappedSecond)); - - var expected = TaggedUnion.Second(mappedSecond); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapAsync_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedFirst = SomeTextStructType; - var mappedSecond = ZeroIdRefType; - - var actual = await source.MapAsync(_ => Task.FromResult(mappedFirst), _ => Task.FromResult(mappedSecond)); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapValueAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapValueAsync.cs deleted file mode 100644 index fd13da8a..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Map/MapValueAsync.cs +++ /dev/null @@ -1,81 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapValueAsync_MapFirstAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapValueAsync(null!, _ => ValueTask.FromResult(157))); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapValueAsync_MapSecondAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapValueAsync(_ => ValueTask.FromResult(1), null!)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task MapValueAsync_SourceIsFirst_ExpectMapppedValueFirstUnion() - { - var sourceValue = new object(); - var source = TaggedUnion.First(sourceValue); - - var mappedFirst = NullTextStructType; - var mappedSecond = ZeroIdRefType; - - var actual = await source.MapValueAsync( - _ => ValueTask.FromResult(mappedFirst), - _ => ValueTask.FromResult(mappedSecond)); - - var expected = TaggedUnion.First(mappedFirst); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapValueAsync_SourceIsSecond_ExpectMappedValueSecondUnion() - { - var sourceValue = default(StructType); - var source = TaggedUnion.Second(sourceValue); - - var mappedFirst = new DateTime(2017, 11, 21); - object? mappedSecond = null; - - var actual = await source.MapValueAsync( - _ => ValueTask.FromResult(mappedFirst), - _ => ValueTask.FromResult(mappedSecond)); - - var expected = TaggedUnion.Second(mappedSecond); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapValueAsync_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedFirst = SomeTextStructType; - var mappedSecond = new object(); - - var actual = await source.MapValueAsync( - _ => ValueTask.FromResult(mappedFirst), - _ => ValueTask.FromResult(mappedSecond)); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirst.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirst.cs deleted file mode 100644 index 0ac83af5..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirst.cs +++ /dev/null @@ -1,55 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapFirst_MapFirstFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws(() => _ = source.MapFirst(null!)); - ClassicAssert.AreEqual("mapFirst", ex!.ParamName); - } - - [Test] - public void MapFirst_SourceIsFirst_ExpectMappedValueFirstUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.First(sourceValue); - - var mappedValue = MinusFifteenIdRefType; - var actual = source.MapFirst(_ => mappedValue); - - var expected = TaggedUnion.First(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void MapFirst_SourceIsSecond_ExpectSourceValueSecondUnion() - { - var sourceValue = new object(); - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = SomeString; - var actual = source.MapFirst(_ => mappedValue); - - var expected = TaggedUnion.Second(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void MapFirst_SourceIsDefault_ExpectDefault() - { - var source = new TaggedUnion(); - - var mappedValue = PlusFifteen; - var actual = source.MapFirst(_ => mappedValue); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstAsync.cs deleted file mode 100644 index a77b675b..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstAsync.cs +++ /dev/null @@ -1,58 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapFirstAsync_MapFirstAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapFirstAsync(null!)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public async Task MapFirstAsync_SourceIsFirst_ExpectMappedValueFirstUnion() - { - var sourceValue = ZeroIdRefType; - var source = TaggedUnion.First(sourceValue); - - StructType? mappedValue = null; - var actual = await source.MapFirstAsync(_ => Task.FromResult(mappedValue)); - - var expected = TaggedUnion.First(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapFirstAsync_SourceIsSecond_ExpectSourceValueSecondUnion() - { - var sourceValue = new object(); - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = EmptyString; - var actual = await source.MapFirstAsync(_ => Task.FromResult(mappedValue)); - - var expected = TaggedUnion.Second(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapFirstAsync_SourceIsDefault_ExpectDefault() - { - var source = new TaggedUnion(); - - var mappedValue = PlusFifteenIdRefType; - var actual = await source.MapFirstAsync(_ => Task.FromResult(mappedValue)); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstValueAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstValueAsync.cs deleted file mode 100644 index f5db7b90..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapFirst/MapFirstValueAsync.cs +++ /dev/null @@ -1,58 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapFirstValueAsync_MapFirstValueAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapFirstValueAsync(null!)); - - ClassicAssert.AreEqual("mapFirstAsync", ex!.ParamName); - } - - [Test] - public async Task MapFirstValueAsync_SourceIsFirst_ExpectMappedValueFirstUnion() - { - object sourceValue = null!; - var source = TaggedUnion.First(sourceValue); - - StructType mappedValue = SomeTextStructType; - var actual = await source.MapFirstValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = TaggedUnion.First(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapFirstValueAsync_SourceIsSecond_ExpectSourceValueSecondUnion() - { - var sourceValue = new { Id = 557 }; - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = ZeroIdRefType; - var actual = await source.MapFirstValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = TaggedUnion.Second(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapFirstValueAsync_SourceIsDefault_ExpectDefault() - { - var source = new TaggedUnion(); - - var mappedValue = PlusFifteenIdRefType; - var actual = await source.MapFirstValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecond.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecond.cs deleted file mode 100644 index 5d86f094..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecond.cs +++ /dev/null @@ -1,55 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapSecond_MapSecondFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws(() => _ = source.MapSecond(null!)); - ClassicAssert.AreEqual("mapSecond", ex!.ParamName); - } - - [Test] - public void MapSecond_SourceIsFirst_ExpectSourceValueFirstUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.First(sourceValue); - - var mappedValue = MinusFifteenIdRefType; - var actual = source.MapSecond(_ => mappedValue); - - var expected = TaggedUnion.First(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void MapSecond_SourceIsSecond_ExpectMappedValueSecondUnion() - { - var sourceValue = new object(); - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = MinusFifteenIdRefType; - var actual = source.MapSecond(_ => mappedValue); - - var expected = TaggedUnion.Second(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void MapSecond_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedValue = MinusFifteen; - var actual = source.MapSecond(_ => mappedValue); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondAsync.cs deleted file mode 100644 index 822d0c1c..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondAsync.cs +++ /dev/null @@ -1,58 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapSecondAsync_MapSecondAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapSecondAsync(null!)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task MapSecondAsync_SourceIsFirst_ExpectSourceValueFirstUnion() - { - RefType? sourceValue = null; - var source = TaggedUnion.First(sourceValue); - - var mappedValue = SomeTextStructType; - var actual = await source.MapSecondAsync(_ => Task.FromResult(mappedValue)); - - var expected = TaggedUnion.First(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapSecondAsync_SourceIsSecond_ExpectMapppedValueSecondUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = new object(); - var actual = await source.MapSecondAsync(_ => Task.FromResult(mappedValue)); - - var expected = TaggedUnion.Second(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapSecondAsync_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedValue = SomeTextStructType; - var actual = await source.MapSecondAsync(_ => Task.FromResult(mappedValue)); - - var expected = default(TaggedUnion); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondValueAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondValueAsync.cs deleted file mode 100644 index 4b4db740..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/MapSecond/MapSecondValueAsync.cs +++ /dev/null @@ -1,58 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void MapSecondValueAsync_MapSecondValueAsyncFuncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync( - async () => _ = await source.MapSecondValueAsync(null!)); - - ClassicAssert.AreEqual("mapSecondAsync", ex!.ParamName); - } - - [Test] - public async Task MapSecondValueAsync_SourceIsFirst_ExpectSourceValueFirstUnion() - { - var sourceValue = SomeString; - var source = TaggedUnion.First(sourceValue); - - RefType? mappedValue = PlusFifteenIdRefType; - var actual = await source.MapSecondValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = TaggedUnion.First(sourceValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapSecondValueAsync_SourceIsSecond_ExpectMapppedValueSecondUnion() - { - var sourceValue = SomeTextStructType; - var source = TaggedUnion.Second(sourceValue); - - var mappedValue = MinusFifteenIdRefType; - var actual = await source.MapSecondValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = TaggedUnion.Second(mappedValue); - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public async Task MapSecondValueAsync_SourceIsDefault_ExpectDefault() - { - var source = default(TaggedUnion); - - var mappedValue = PlusFifteenIdRefType; - var actual = await source.MapSecondValueAsync(_ => ValueTask.FromResult(mappedValue)); - - var expected = new TaggedUnion(); - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/Or.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/Or.cs deleted file mode 100644 index 97649b4f..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/Or.cs +++ /dev/null @@ -1,47 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void Or_OtherFactoryIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.Throws(() => _ = source.Or(null!)); - ClassicAssert.AreEqual("otherFactory", ex!.ParamName); - } - - [Test] - public void Or_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(new object()); - var other = TaggedUnion.Second(SomeTextStructType); - - var actual = source.Or(() => other); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public void Or_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(ZeroIdRefType); - var other = TaggedUnion.Second(PlusFifteenIdRefType); - - var actual = source.Or(() => other); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public void Or_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - var other = TaggedUnion.First(new object()); - - var actual = source.Or(() => other); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrAsync.cs deleted file mode 100644 index ab75790e..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrAsync.cs +++ /dev/null @@ -1,48 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void OrAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync(async () => _ = await source.OrAsync(null!)); - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task OrAsync_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(null); - var other = TaggedUnion.First(ZeroIdRefType); - - var actual = await source.OrAsync(() => Task.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrAsync_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(SomeTextStructType); - var other = default(TaggedUnion); - - var actual = await source.OrAsync(() => Task.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrAsync_SourceIsDefault_ExpectOther() - { - var source = default(TaggedUnion); - var other = TaggedUnion.Second(new RefType()); - - var actual = await source.OrAsync(() => Task.FromResult(other)); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrValueAsync.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrValueAsync.cs deleted file mode 100644 index a3fc2ffd..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/Or/OrValueAsync.cs +++ /dev/null @@ -1,48 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Threading.Tasks; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.TaggedUnionTestSource))] - public void OrValueAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullException( - TaggedUnion source) - { - var ex = Assert.ThrowsAsync(async () => _ = await source.OrValueAsync(null!)); - ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName); - } - - [Test] - public async Task OrValueAsync_SourceIsFirst_ExpectSource() - { - var source = TaggedUnion.First(SomeTextStructType); - var other = default(TaggedUnion); - - var actual = await source.OrValueAsync(() => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrValueAsync_SourceIsSecond_ExpectSource() - { - var source = TaggedUnion.Second(default); - var other = TaggedUnion.Second(SomeTextStructType); - - var actual = await source.OrValueAsync(() => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(source, actual); - } - - [Test] - public async Task OrValueAsync_SourceIsDefault_ExpectOther() - { - var source = new TaggedUnion(); - var other = TaggedUnion.First(MinusFifteenIdRefType); - - var actual = await source.OrValueAsync(() => ValueTask.FromResult(other)); - ClassicAssert.AreEqual(other, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.ExceptionFactory.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.ExceptionFactory.cs deleted file mode 100644 index 71712b32..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.ExceptionFactory.cs +++ /dev/null @@ -1,53 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void FirstOrThrowWithFactory_ExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.First(SomeTextStructType); - - var ex = Assert.Throws(() => _ = source.FirstOrThrow(null!)); - ClassicAssert.AreEqual("exceptionFactory", ex!.ParamName); - } - - [Test] - public void FirstOrThrowWithFactory_SourceIsFirst_ExpectSourceValue() - { - var sourceValue = SomeTextStructType; - TaggedUnion source = sourceValue; - - var resultException = new SomeException(); - - var actual = source.FirstOrThrow(() => resultException); - ClassicAssert.AreEqual(sourceValue, actual); - } - - [Test] - public void FirstOrThrowWithFactory_SourceIsSecond_ExpectCreatedException() - { - var source = TaggedUnion.Second(new object()); - var resultException = new SomeException(); - - var actualException = Assert.Throws( - () => _ = source.FirstOrThrow(() => resultException)); - - ClassicAssert.AreSame(resultException, actualException); - } - - [Test] - public void FirstOrThrowWithFactory_SourceIsDefault_ExpectInvalidOperationException() - { - var source = default(TaggedUnion); - var resultException = new SomeException(); - - var actualException = Assert.Throws( - () => _ = source.FirstOrThrow(() => resultException)); - - ClassicAssert.AreSame(resultException, actualException); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.cs deleted file mode 100644 index 158a3579..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/FirstOrThrow.cs +++ /dev/null @@ -1,37 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void FirstOrThrow_SourceIsFirst_ExpectSourceValue( - object? sourceValue) - { - var source = TaggedUnion.First(sourceValue); - - var actual = source.FirstOrThrow(); - ClassicAssert.AreEqual(sourceValue, actual); - } - - [Test] - public void FirstOrThrow_SourceIsSecond_ExpectInvalidOperationException() - { - var source = TaggedUnion.Second(PlusFifteenIdRefType); - - var ex = Assert.Throws(() => _ = source.FirstOrThrow()); - AssertContains(First, ex!.Message); - } - - [Test] - public void FirstOrThrow_SourceIsDefault_ExpectInvalidOperationException() - { - var source = default(TaggedUnion); - - var ex = Assert.Throws(() => _ = source.FirstOrThrow()); - AssertContains(First, ex!.Message); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.ExceptionFactory.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.ExceptionFactory.cs deleted file mode 100644 index f631feab..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.ExceptionFactory.cs +++ /dev/null @@ -1,53 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void SecondOrThrowWithFactory_ExceptionFactoryIsNull_ExpectArgumentNullException() - { - var source = TaggedUnion.Second(MinusFifteenIdRefType); - - var ex = Assert.Throws(() => _ = source.SecondOrThrow(null!)); - ClassicAssert.AreEqual("exceptionFactory", ex!.ParamName); - } - - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void SecondOrThrowWithFactory_SourceIsSecond_ExpectSourceValue( - object? sourceValue) - { - var source = TaggedUnion.Second(sourceValue); - var resultException = new SomeException(); - - var actual = source.SecondOrThrow(() => resultException); - ClassicAssert.AreEqual(sourceValue, actual); - } - - [Test] - public void SecondOrThrowWithFactory_SourceIsFirst_ExpectCreatedException() - { - var source = TaggedUnion.First(ZeroIdRefType); - var resultException = new SomeException(); - - var actualExcepption = Assert.Throws( - () => _ = source.SecondOrThrow(() => resultException)); - - ClassicAssert.AreSame(resultException, actualExcepption); - } - - [Test] - public void SecondOrThrowWithFactory_SourceIsDefault_ExpectInvalidOperationException() - { - var source = default(TaggedUnion); - var resultException = new SomeException(); - - var actualExcepption = Assert.Throws( - () => _ = source.SecondOrThrow(() => resultException)); - - ClassicAssert.AreSame(resultException, actualExcepption); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.cs deleted file mode 100644 index b6ba57e2..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/OrThrow/SecondOrThrow.cs +++ /dev/null @@ -1,36 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void SecondOrThrow_SourceIsSecond_ExpectSourceValue() - { - var sourceValue = MinusFifteenIdRefType; - TaggedUnion source = sourceValue; - - var actual = source.SecondOrThrow(); - ClassicAssert.AreEqual(sourceValue, actual); - } - - [Test] - public void SecondOrThrow_SourceIsFirst_ExpectInvalidOperationException() - { - var source = TaggedUnion.First(new { Text = SomeString }); - - var ex = Assert.Throws(() => _ = source.SecondOrThrow()); - AssertContains(Second, ex!.Message); - } - - [Test] - public void SecondOrThrow_SourceIsDefault_ExpectInvalidOperationException() - { - var source = default(TaggedUnion); - - var ex = Assert.Throws(() => _ = source.SecondOrThrow()); - AssertContains(Second, ex!.Message); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/TaggedUnionTest.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/TaggedUnionTest.cs deleted file mode 100644 index d4029d35..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/TaggedUnionTest.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace PrimeFuncPack.Core.Tests; - -public sealed partial class TaggedUnionTest -{ - private const string First = "First"; - - private const string Second = "Second"; - - private static void AssertContains( - string expectedSubstring, - string? actual, - StringComparison comparison = StringComparison.Ordinal) - { - ClassicAssert.NotNull(actual); - ClassicAssert.True(actual!.Contains(expectedSubstring, comparison)); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.First.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.First.cs deleted file mode 100644 index 540a5d74..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.First.cs +++ /dev/null @@ -1,124 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Globalization; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void ToString_SourceIsFirstAndValueIsNull() - { - var source = TaggedUnion.First(null); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:First:{2}", - typeof(object).Name, - typeof(StructType).Name, - string.Empty); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void ToString_SourceIsFirstAndValueToStringReturnsNull() - { - var sourceValue = new StubToStringType(null); - var source = TaggedUnion.First(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:First:{2}", - typeof(StubToStringType).Name, - typeof(RefType).Name, - string.Empty); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCase(null)] - [TestCase(EmptyString)] - [TestCase(TabString)] - [TestCase(TwoTabsString)] - [TestCase(WhiteSpaceString)] - [TestCase(TwoWhiteSpacesString)] - [TestCase(ThreeWhiteSpacesString)] - [TestCase(MixedWhiteSpacesString)] - [TestCase(SomeString)] - public void ToString_SourceIsFirst_ValueToString_Common( - string? resultOfValueToString) - { - var sourceValue = new StubToStringType(resultOfValueToString); - var source = TaggedUnion.First(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:First:{2}", - typeof(StubToStringType).Name, - typeof(RefType).Name, - resultOfValueToString); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCase(null)] - [TestCase(EmptyString)] - [TestCase(TabString)] - [TestCase(TwoTabsString)] - [TestCase(WhiteSpaceString)] - [TestCase(TwoWhiteSpacesString)] - [TestCase(ThreeWhiteSpacesString)] - [TestCase(MixedWhiteSpacesString)] - [TestCase(SomeString)] - [TestCase(MinusOne)] - [TestCase(Zero)] - [TestCase(One)] - public void ToString_SourceIsFirst_Common( - object? sourceValue) - { - var source = TaggedUnion.First(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:First:{2}", - typeof(object).Name, - typeof(RefType).Name, - sourceValue); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCaseSource(nameof(ToString_SourceIsFirst_DecimalPoint_TestCaseSource))] - public void ToString_SourceIsFirst_DecimalPoint( - decimal sourceValue, string expectedDecimalSubstr) - { - var source = TaggedUnion.First(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:First:{2}", - typeof(object).Name, - typeof(RefType).Name, - expectedDecimalSubstr); - - ClassicAssert.AreEqual(expected, actual); - } - - private static IEnumerable ToString_SourceIsFirst_DecimalPoint_TestCaseSource() - { - yield return new object[] { -1.1m, "-1.1" }; - yield return new object[] { 0.0m, "0.0" }; - yield return new object[] { 1.1m, "1.1" }; - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.None.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.None.cs deleted file mode 100644 index b63a3440..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.None.cs +++ /dev/null @@ -1,24 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Globalization; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void ToString_SourceIsNone() - { - var source = default(TaggedUnion); - - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:None:()", - typeof(StructType).Name, - typeof(RefType).Name); - - ClassicAssert.AreEqual(expected, actual); - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.Second.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.Second.cs deleted file mode 100644 index ff0b0d78..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Test/ToString/ToString.Second.cs +++ /dev/null @@ -1,124 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Globalization; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionTest -{ - [Test] - public void ToString_SourceIsSecondAndValueIsNull() - { - var source = TaggedUnion.Second(null); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:Second:{2}", - typeof(decimal).Name, - typeof(StructType?).Name, - string.Empty); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - public void ToString_SourceIsSecondAndValueToStringReturnsNull() - { - var sourceValue = new StubToStringType(null); - var source = TaggedUnion.Second(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:Second:{2}", - typeof(string).Name, - typeof(StubToStringType).Name, - string.Empty); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCase(null)] - [TestCase(EmptyString)] - [TestCase(TabString)] - [TestCase(TwoTabsString)] - [TestCase(WhiteSpaceString)] - [TestCase(TwoWhiteSpacesString)] - [TestCase(ThreeWhiteSpacesString)] - [TestCase(MixedWhiteSpacesString)] - [TestCase(SomeString)] - public void ToString_SourceIsSecond_ValueToString_Common( - string? resultOfValueToString) - { - var sourceValue = new StubToStringType(resultOfValueToString); - var source = TaggedUnion.Second(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:Second:{2}", - typeof(StructType).Name, - typeof(StubToStringType).Name, - resultOfValueToString); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCase(null)] - [TestCase(EmptyString)] - [TestCase(TabString)] - [TestCase(TwoTabsString)] - [TestCase(WhiteSpaceString)] - [TestCase(TwoWhiteSpacesString)] - [TestCase(ThreeWhiteSpacesString)] - [TestCase(MixedWhiteSpacesString)] - [TestCase(SomeString)] - [TestCase(MinusOne)] - [TestCase(Zero)] - [TestCase(One)] - public void ToString_SourceIsSecond_Common( - object? sourceValue) - { - var source = TaggedUnion.Second(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:Second:{2}", - typeof(StructType).Name, - typeof(object).Name, - sourceValue); - - ClassicAssert.AreEqual(expected, actual); - } - - [Test] - [TestCaseSource(nameof(ToString_SourceIsSecond_DecimalPoint_TestCaseSource))] - public void ToString_SourceIsSecond_DecimalPoint( - object? sourceValue, string expectedDecimalSubstr) - { - var source = TaggedUnion.Second(sourceValue); - var actual = source.ToString(); - - var expected = string.Format( - CultureInfo.InvariantCulture, - "TaggedUnion<{0}, {1}>:Second:{2}", - typeof(StructType).Name, - typeof(object).Name, - expectedDecimalSubstr); - - ClassicAssert.AreEqual(expected, actual); - } - - private static IEnumerable ToString_SourceIsSecond_DecimalPoint_TestCaseSource() - { - yield return new object[] { -1.1m, "-1.1" }; - yield return new object[] { 0.0m, "0.0" }; - yield return new object[] { 1.1m, "1.1" }; - } -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Tests.Old.csproj b/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Tests.Old.csproj deleted file mode 100644 index affe990a..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TaggedUnion.Tests.Old.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - net6.0;net7.0;net8.0 - latest - disable - enable - true - true - false - true - Andrei Sergeev, Pavel Moskovoy - Copyright © 2020-2024 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack.Core.Tests - PrimeFuncPack.Core.TaggedUnion.Tests.Old - - - - CS0618;NUnit2001;NUnit2004;NUnit2005;NUnit2006;NUnit2015;NUnit2017;NUnit2018 - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/SomeException.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/SomeException.cs deleted file mode 100644 index 5e87017e..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/SomeException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace PrimeFuncPack.Core.Tests; - -internal sealed class SomeException : Exception -{ -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/StubToStringType.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/StubToStringType.cs deleted file mode 100644 index 18fa51c3..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/StubToStringType.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace PrimeFuncPack.Core.Tests; - -internal sealed class StubToStringType -{ - private readonly string? toStringValue; - - public StubToStringType( - string? toStringValue) - => - this.toStringValue = toStringValue; - - public override string? ToString() - => toStringValue; -} diff --git a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/TestDataSource.cs b/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/TestDataSource.cs deleted file mode 100644 index c7bffbb4..00000000 --- a/src/core-taggeds-union/TaggedUnion.Tests.Old/TestData/TestDataSource.cs +++ /dev/null @@ -1,41 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using System.Collections.Generic; -using System.Linq; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -internal static class TestDataSource -{ - public static IEnumerable ObjectNullableTestSource - => - new object?[] - { - null, - new object(), - MinusFifteen, - PlusFifteenIdRefType, - SomeTextStructType - } - .ToNullableTestSource(); - - public static IEnumerable TaggedUnionTestSource - => - new[] - { - default(TaggedUnion), - TaggedUnion.First(PlusFifteenIdRefType), - TaggedUnion.Second(SomeTextStructType) - } - .ToNotNullableTestSource(); - - private static IEnumerable ToNullableTestSource(this IEnumerable source) - => - source.Select(v => new[] { v }); - - private static IEnumerable ToNotNullableTestSource(this IEnumerable source) - where T : notnull - => - source.Select(v => new object[] { v }); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T.Extensions.Obsolete/Extensions.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T.Extensions.Obsolete/Extensions.cs deleted file mode 100644 index 847325d5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T.Extensions.Obsolete/Extensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -// TODO: Remove the class in v3.0 -[Obsolete(InnerClassObsoleteMessage, error: true)] -public static class TaggedUnionExtensions -{ - private const string InnerClassObsoleteMessage - = - "This class is obsolete. Use TaggedUnion instance methods instead."; - - private const string InnerOrInitializeMethodObsoleteMessage - = - "This method is obsolete. Call TaggedUnion Or instance method instead."; - - private const string InnerOrInitializeAsyncMethodObsoleteMessage - = - "This method is obsolete. Call TaggedUnion OrAsync instance method instead."; - - private const string InnerOrInitializeValueAsyncMethodObsoleteMessage - = - "This method is obsolete. Call TaggedUnion OrValueAsync instance method instead."; - - [Obsolete(InnerOrInitializeMethodObsoleteMessage, error: true)] - public static TaggedUnion OrInitialize( - TaggedUnion union, - Func> otherFactory) - => - union.Or( - otherFactory ?? throw new ArgumentNullException(nameof(otherFactory))); - - [Obsolete(InnerOrInitializeAsyncMethodObsoleteMessage, error: true)] - public static Task> OrInitializeAsync( - TaggedUnion union, - Func>> otherFactoryAsync) - => - union.OrAsync( - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); - - [Obsolete(InnerOrInitializeValueAsyncMethodObsoleteMessage, error: true)] - public static ValueTask> OrInitializeValueAsync( - TaggedUnion union, - Func>> otherFactoryAsync) - => - union.OrValueAsync( - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner.Tag/TaggedUnion.T.Tag.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner.Tag/TaggedUnion.T.Tag.cs deleted file mode 100644 index 61e58f53..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner.Tag/TaggedUnion.T.Tag.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - private enum Tag - { - None, - First, - Second - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerExceptionFactories.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerExceptionFactories.cs deleted file mode 100644 index 48a78a39..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerExceptionFactories.cs +++ /dev/null @@ -1,18 +0,0 @@ -using static System.FormattableString; - -namespace System; - -partial struct TaggedUnion -{ - private static InvalidOperationException InnerCreateExpectedFirstException() - => - new(InnerCreateExpectedTagMessage(Tag.First)); - - private static InvalidOperationException InnerCreateExpectedSecondException() - => - new(InnerCreateExpectedTagMessage(Tag.Second)); - - private static string InnerCreateExpectedTagMessage(Tag tag) - => - Invariant($"The tagged union is expected to represent the {tag} case."); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.Value.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.Value.cs deleted file mode 100644 index 8d245cc2..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.Value.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ValueTask InnerFoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first)!; - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second)!; - } - - return ValueTask.FromResult(default); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ValueTask InnerFoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - TResult other) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return ValueTask.FromResult(other); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ValueTask InnerFoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func otherFactory) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return ValueTask.FromResult(otherFactory.Invoke()); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ValueTask InnerFoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func> otherFactoryAsync) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return otherFactoryAsync.Invoke(); - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.cs deleted file mode 100644 index d6f16b8c..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Async.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Task InnerFoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first)!; - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second)!; - } - - return Task.FromResult(default); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Task InnerFoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - TResult other) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return Task.FromResult(other); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Task InnerFoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func otherFactory) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return Task.FromResult(otherFactory.Invoke()); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Task InnerFoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func> otherFactoryAsync) - { - if (tag is Tag.First) - { - return mapFirstAsync.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecondAsync.Invoke(second); - } - - return otherFactoryAsync.Invoke(); - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Sync.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Sync.cs deleted file mode 100644 index 8963ff81..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerFold.Sync.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TResult? InnerFold( - Func mapFirst, - Func mapSecond) - { - if (tag is Tag.First) - { - return mapFirst.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecond.Invoke(second); - } - - return default; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TResult InnerFold( - Func mapFirst, - Func mapSecond, - TResult other) - { - if (tag is Tag.First) - { - return mapFirst.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecond.Invoke(second); - } - - return other; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TResult InnerFold( - Func mapFirst, - Func mapSecond, - Func otherFactory) - { - if (tag is Tag.First) - { - return mapFirst.Invoke(first); - } - - if (tag is Tag.Second) - { - return mapSecond.Invoke(second); - } - - return otherFactory.Invoke(); - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMap.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMap.cs deleted file mode 100644 index c0018a72..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMap.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - private TaggedUnion InnerMap( - Func mapFirst, - Func mapSecond) - { - if (tag is Tag.First) - { - return new(mapFirst.Invoke(first)); - } - - if (tag is Tag.Second) - { - return new(mapSecond.Invoke(second)); - } - - return default; - } - - private async Task> InnerMapAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return new(await mapFirstAsync.Invoke(first).ConfigureAwait(false)); - } - - if (tag is Tag.Second) - { - return new(await mapSecondAsync.Invoke(second).ConfigureAwait(false)); - } - - return default; - } - - private async ValueTask> InnerMapValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return new(await mapFirstAsync.Invoke(first).ConfigureAwait(false)); - } - - if (tag is Tag.Second) - { - return new(await mapSecondAsync.Invoke(second).ConfigureAwait(false)); - } - - return default; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapFirst.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapFirst.cs deleted file mode 100644 index e0cfd504..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapFirst.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - private TaggedUnion InnerMapFirst( - Func mapFirst) - { - if (tag is Tag.First) - { - return new(mapFirst.Invoke(first)); - } - - if (tag is Tag.Second) - { - return new(second); - } - - return default; - } - - private async Task> InnerMapFirstAsync( - Func> mapFirstAsync) - { - if (tag is Tag.First) - { - return new(await mapFirstAsync.Invoke(first).ConfigureAwait(false)); - } - - if (tag is Tag.Second) - { - return new(second); - } - - return default; - } - - private async ValueTask> InnerMapFirstValueAsync( - Func> mapFirstAsync) - { - if (tag is Tag.First) - { - return new(await mapFirstAsync.Invoke(first).ConfigureAwait(false)); - } - - if (tag is Tag.Second) - { - return new(second); - } - - return default; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapSecond.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapSecond.cs deleted file mode 100644 index 700644b3..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerMapSecond.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - private TaggedUnion InnerMapSecond( - Func mapSecond) - { - if (tag is Tag.First) - { - return new(first); - } - - if (tag is Tag.Second) - { - return new(mapSecond.Invoke(second)); - } - - return default; - } - - private async Task> InnerMapSecondAsync( - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return new(first); - } - - if (tag is Tag.Second) - { - return new(await mapSecondAsync.Invoke(second).ConfigureAwait(false)); - } - - return default; - } - - private async ValueTask> InnerMapSecondValueAsync( - Func> mapSecondAsync) - { - if (tag is Tag.First) - { - return new(first); - } - - if (tag is Tag.Second) - { - return new(await mapSecondAsync.Invoke(second).ConfigureAwait(false)); - } - - return default; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.TUnit.cs deleted file mode 100644 index ccda7a23..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.TUnit.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOn( - Func onFirst, - Func onSecond) - { - if (tag is Tag.First) - { - _ = onFirst.Invoke(first); - } - else if (tag is Tag.Second) - { - _ = onSecond.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnAsync( - Func> onFirstAsync, - Func> onSecondAsync) - { - if (tag is Tag.First) - { - _ = await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - _ = await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnValueAsync( - Func> onFirstAsync, - Func> onSecondAsync) - { - if (tag is Tag.First) - { - _ = await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - _ = await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.Unit.cs deleted file mode 100644 index f0d1b9e5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.Unit.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOn( - Func onFirst, - Func onSecond) - { - if (tag is Tag.First) - { - _ = onFirst.Invoke(first); - } - else if (tag is Tag.Second) - { - _ = onSecond.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnAsync( - Func> onFirstAsync, - Func> onSecondAsync) - { - if (tag is Tag.First) - { - _ = await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - _ = await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnValueAsync( - Func> onFirstAsync, - Func> onSecondAsync) - { - if (tag is Tag.First) - { - _ = await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - _ = await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.cs deleted file mode 100644 index c0f7ec0e..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOn.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOn( - Action onFirst, - Action onSecond) - { - if (tag is Tag.First) - { - onFirst.Invoke(first); - } - else if (tag is Tag.Second) - { - onSecond.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnAsync( - Func onFirstAsync, - Func onSecondAsync) - { - if (tag is Tag.First) - { - await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnValueAsync( - Func onFirstAsync, - Func onSecondAsync) - { - if (tag is Tag.First) - { - await onFirstAsync.Invoke(first).ConfigureAwait(false); - } - else if (tag is Tag.Second) - { - await onSecondAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.TUnit.cs deleted file mode 100644 index e605fb5c..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.TUnit.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnFirst( - Func handler) - { - if (tag is Tag.First) - { - _ = handler.Invoke(first); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnFirstAsync( - Func> handlerAsync) - { - if (tag is Tag.First) - { - _ = await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnFirstValueAsync( - Func> handlerAsync) - { - if (tag is Tag.First) - { - _ = await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.Unit.cs deleted file mode 100644 index c367ede7..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.Unit.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnFirst( - Func handler) - { - if (tag is Tag.First) - { - _ = handler.Invoke(first); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnFirstAsync( - Func> handlerAsync) - { - if (tag is Tag.First) - { - _ = await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnFirstValueAsync( - Func> handlerAsync) - { - if (tag is Tag.First) - { - _ = await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.cs deleted file mode 100644 index ab388732..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnFirst.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnFirst( - Action handler) - { - if (tag is Tag.First) - { - handler.Invoke(first); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnFirstAsync( - Func handlerAsync) - { - if (tag is Tag.First) - { - await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnFirstValueAsync( - Func handlerAsync) - { - if (tag is Tag.First) - { - await handlerAsync.Invoke(first).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.TUnit.cs deleted file mode 100644 index 8764a823..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.TUnit.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnSecond( - Func handler) - { - if (tag is Tag.Second) - { - _ = handler.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnSecondAsync( - Func> handlerAsync) - { - if (tag is Tag.Second) - { - _ = await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnSecondValueAsync( - Func> handlerAsync) - { - if (tag is Tag.Second) - { - _ = await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.Unit.cs deleted file mode 100644 index 47fc9c2b..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.Unit.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnSecond( - Func handler) - { - if (tag is Tag.Second) - { - _ = handler.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnSecondAsync( - Func> handlerAsync) - { - if (tag is Tag.Second) - { - _ = await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnSecondValueAsync( - Func> handlerAsync) - { - if (tag is Tag.Second) - { - _ = await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.cs deleted file mode 100644 index fd643baf..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOnSecond.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOnSecond( - Action handler) - { - if (tag is Tag.Second) - { - handler.Invoke(second); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task> InnerOnSecondAsync( - Func handlerAsync) - { - if (tag is Tag.Second) - { - await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async ValueTask> InnerOnSecondValueAsync( - Func handlerAsync) - { - if (tag is Tag.Second) - { - await handlerAsync.Invoke(second).ConfigureAwait(false); - } - - return this; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOr.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOr.cs deleted file mode 100644 index e6fda1bd..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOr.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TaggedUnion InnerOr( - Func> otherFactory) - => - tag is not Tag.None ? this : otherFactory.Invoke(); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private Task> InnerOrAsync( - Func>> otherFactoryAsync) - => - tag is not Tag.None ? Task.FromResult(this) : otherFactoryAsync.Invoke(); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ValueTask> InnerOrValueAsync( - Func>> otherFactoryAsync) - => - tag is not Tag.None ? ValueTask.FromResult(this) : otherFactoryAsync.Invoke(); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.First.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.First.cs deleted file mode 100644 index d52631b6..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.First.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TFirst InnerFirstOrThrow(Func exceptionFactory) - => - tag is Tag.First ? first : throw exceptionFactory.Invoke(); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.Second.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.Second.cs deleted file mode 100644 index cd7ef6b2..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerOrThrow.Second.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private TSecond InnerSecondOrThrow(Func exceptionFactory) - => - tag is Tag.Second ? second : throw exceptionFactory.Invoke(); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerToString.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerToString.cs deleted file mode 100644 index 68e5677a..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/Inner/TaggedUnion.T.InnerToString.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Runtime.CompilerServices; -using static System.FormattableString; - -namespace System; - -partial struct TaggedUnion -{ - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private string InnerToString() - => - InnerFold( - first => InnerToString("First", first), - second => InnerToString("Second", second), - () => InnerToString("None", "()")); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static string InnerToString(string tag, TValue value) - => - Invariant($"TaggedUnion<{typeof(TFirst).Name}, {typeof(TSecond).Name}>:{tag}:{value}"); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.Wrap.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.Wrap.cs deleted file mode 100644 index f5b59d34..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.Wrap.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace System; - -partial struct TaggedUnion -{ - public static bool Equals(TaggedUnion left, TaggedUnion right) - => - left.Equals(right); - - public static bool operator ==(TaggedUnion left, TaggedUnion right) - => - left.Equals(right); - - public static bool operator !=(TaggedUnion left, TaggedUnion right) - => - left.Equals(right) is false; - - public override bool Equals([NotNullWhen(true)] object? obj) - => - obj is TaggedUnion other && - Equals(other); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.cs deleted file mode 100644 index af00d46c..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.Equals.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; - -namespace System; - -partial struct TaggedUnion -{ - public bool Equals(TaggedUnion other) - { - if (tag != other.tag) - { - return false; - } - - if (tag is Tag.First) - { - return EqualityComparer.Default.Equals(first, other.first); - } - - if (tag is Tag.Second) - { - return EqualityComparer.Default.Equals(second, other.second); - } - - return true; - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.GetHashCode.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.GetHashCode.cs deleted file mode 100644 index 6ee49c24..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Equality.GetHashCode.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace System; - -partial struct TaggedUnion -{ - public override int GetHashCode() - { - if (tag is Tag.First) - { - return PresentHashCode(first); - } - - if (tag is Tag.Second) - { - return PresentHashCode(second); - } - - return NoneHashCode(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private int PresentHashCode(TValue value) - => - value is not null - ? HashCode.Combine(EqualityContractHashCode(), tag, EqualityComparer.Default.GetHashCode(value)) - : HashCode.Combine(EqualityContractHashCode(), tag); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int NoneHashCode() - => - HashCode.Combine(EqualityContractHashCode()); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int EqualityContractHashCode() - => - EqualityComparer.Default.GetHashCode(typeof(TaggedUnion)); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.Equality.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.Equality.cs deleted file mode 100644 index 3642dfb3..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.Equality.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.CompilerServices; - -namespace System; - -partial struct TaggedUnion -{ - partial class EqualityComparer - { - public bool Equals(TaggedUnion x, TaggedUnion y) - { - if (x.tag != y.tag) - { - return false; - } - - if (x.tag is Tag.First) - { - return firstComparer.Equals(x.first, y.first); - } - - if (x.tag is Tag.Second) - { - return secondComparer.Equals(x.second, y.second); - } - - return true; - } - - public int GetHashCode(TaggedUnion obj) - { - if (obj.tag is Tag.First) - { - return PresentHashCode(Tag.First, obj.first, firstComparer); - } - - if (obj.tag is Tag.Second) - { - return PresentHashCode(Tag.Second, obj.second, secondComparer); - } - - return NoneHashCode(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int PresentHashCode(Tag tag, TValue value, IEqualityComparer comparer) - => - value is not null - ? HashCode.Combine(tag, comparer.GetHashCode(value)) - : HashCode.Combine(tag); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static int NoneHashCode() - => - HashCode.Combine(Tag.None); - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.cs deleted file mode 100644 index 0a3dc81e..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.EqualityComparer.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections.Generic; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the class - internal sealed partial class EqualityComparer : IEqualityComparer> - { - private readonly IEqualityComparer firstComparer; - - private readonly IEqualityComparer secondComparer; - - private EqualityComparer( - IEqualityComparer firstComparer, - IEqualityComparer secondComparer) - { - this.firstComparer = firstComparer; - this.secondComparer = secondComparer; - } - - public static EqualityComparer Create( - IEqualityComparer? firstComparer, - IEqualityComparer? secondComparer) - => - new( - firstComparer ?? EqualityComparer.Default, - secondComparer ?? EqualityComparer.Default); - - public static EqualityComparer Create(IEqualityComparer? firstComparer) - => - new( - firstComparer ?? EqualityComparer.Default, - EqualityComparer.Default); - - public static EqualityComparer Create(IEqualityComparer? secondComparer) - => - new( - EqualityComparer.Default, - secondComparer ?? EqualityComparer.Default); - - public static EqualityComparer Create() - => - new( - EqualityComparer.Default, - EqualityComparer.Default); - - public static EqualityComparer Default - => - InnerDefault.Value; - - private static class InnerDefault - { - internal static readonly EqualityComparer Value = Create(); - } - } -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Constructor.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Constructor.cs deleted file mode 100644 index 40687ae5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Constructor.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public TaggedUnion(TFirst first) - => - (this.first, tag, second) = (first, Tag.First, default!); - - public TaggedUnion(TSecond second) - => - (this.second, tag, first) = (second, Tag.Second, default!); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Explicit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Explicit.cs deleted file mode 100644 index 4f448980..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Explicit.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public static TaggedUnion First(TFirst first) - => - new(first); - - public static TaggedUnion Second(TSecond second) - => - new(second); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Implicit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Implicit.cs deleted file mode 100644 index a8bcd43d..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Factory.Implicit.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public static implicit operator TaggedUnion(TFirst first) - => - new(first); - - public static implicit operator TaggedUnion(TSecond second) - => - new(second); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.Value.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.Value.cs deleted file mode 100644 index 44a971d8..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.Value.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the method - internal ValueTask FoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - => - InnerFoldValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); - - public ValueTask FoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - TResult other) - => - InnerFoldValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - other); - - public ValueTask FoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func otherFactory) - => - InnerFoldValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - otherFactory ?? throw new ArgumentNullException(nameof(otherFactory))); - - public ValueTask FoldValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func> otherFactoryAsync) - => - InnerFoldValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.cs deleted file mode 100644 index c5bdb7ad..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Async.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the method - internal Task FoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - => - InnerFoldAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); - - public Task FoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - TResult other) - => - InnerFoldAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - other); - - public Task FoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func otherFactory) - => - InnerFoldAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - otherFactory ?? throw new ArgumentNullException(nameof(otherFactory))); - - public Task FoldAsync( - Func> mapFirstAsync, - Func> mapSecondAsync, - Func> otherFactoryAsync) - => - InnerFoldAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync)), - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Sync.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Sync.cs deleted file mode 100644 index 9684a178..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Fold.Sync.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public TResult? Fold( - Func mapFirst, - Func mapSecond) - => - InnerFold( - mapFirst ?? throw new ArgumentNullException(nameof(mapFirst)), - mapSecond ?? throw new ArgumentNullException(nameof(mapSecond))); - - public TResult Fold( - Func mapFirst, - Func mapSecond, - TResult other) - => - InnerFold( - mapFirst ?? throw new ArgumentNullException(nameof(mapFirst)), - mapSecond ?? throw new ArgumentNullException(nameof(mapSecond)), - other); - - public TResult Fold( - Func mapFirst, - Func mapSecond, - Func otherFactory) - => - InnerFold( - mapFirst ?? throw new ArgumentNullException(nameof(mapFirst)), - mapSecond ?? throw new ArgumentNullException(nameof(mapSecond)), - otherFactory ?? throw new ArgumentNullException(nameof(otherFactory))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Map.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Map.cs deleted file mode 100644 index 3e77103a..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Map.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - public TaggedUnion Map( - Func mapFirst, - Func mapSecond) - => - InnerMap( - mapFirst ?? throw new ArgumentNullException(nameof(mapFirst)), - mapSecond ?? throw new ArgumentNullException(nameof(mapSecond))); - - public Task> MapAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - => - InnerMapAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); - - public ValueTask> MapValueAsync( - Func> mapFirstAsync, - Func> mapSecondAsync) - => - InnerMapValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync)), - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapFirst.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapFirst.cs deleted file mode 100644 index 2d7a2585..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapFirst.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - public TaggedUnion MapFirst( - Func mapFirst) - => - InnerMapFirst( - mapFirst ?? throw new ArgumentNullException(nameof(mapFirst))); - - public Task> MapFirstAsync( - Func> mapFirstAsync) - => - InnerMapFirstAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync))); - - public ValueTask> MapFirstValueAsync( - Func> mapFirstAsync) - => - InnerMapFirstValueAsync( - mapFirstAsync ?? throw new ArgumentNullException(nameof(mapFirstAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapSecond.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapSecond.cs deleted file mode 100644 index e5b0a5e7..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.MapSecond.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - public TaggedUnion MapSecond( - Func mapSecond) - => - InnerMapSecond( - mapSecond ?? throw new ArgumentNullException(nameof(mapSecond))); - - public Task> MapSecondAsync( - Func> mapSecondAsync) - => - InnerMapSecondAsync( - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); - - public ValueTask> MapSecondValueAsync( - Func> mapSecondAsync) - => - InnerMapSecondValueAsync( - mapSecondAsync ?? throw new ArgumentNullException(nameof(mapSecondAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.TUnit.cs deleted file mode 100644 index 6feeda9b..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.TUnit.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion On( - Func onFirst, - Func onSecond) - => - InnerOn( - onFirst ?? throw new ArgumentNullException(nameof(onFirst)), - onSecond ?? throw new ArgumentNullException(nameof(onSecond))); - - internal Task> OnAsync( - Func> onFirstAsync, - Func> onSecondAsync) - => - InnerOnAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); - - internal ValueTask> OnValueAsync( - Func> onFirstAsync, - Func> onSecondAsync) - => - InnerOnValueAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.Unit.cs deleted file mode 100644 index 417be28b..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.Unit.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion On( - Func onFirst, - Func onSecond) - => - InnerOn( - onFirst ?? throw new ArgumentNullException(nameof(onFirst)), - onSecond ?? throw new ArgumentNullException(nameof(onSecond))); - - internal Task> OnAsync( - Func> onFirstAsync, - Func> onSecondAsync) - => - InnerOnAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); - - internal ValueTask> OnValueAsync( - Func> onFirstAsync, - Func> onSecondAsync) - => - InnerOnValueAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.cs deleted file mode 100644 index 754ab2d0..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.On.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion On( - Action onFirst, - Action onSecond) - => - InnerOn( - onFirst ?? throw new ArgumentNullException(nameof(onFirst)), - onSecond ?? throw new ArgumentNullException(nameof(onSecond))); - - internal Task> OnAsync( - Func onFirstAsync, - Func onSecondAsync) - => - InnerOnAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); - - internal ValueTask> OnValueAsync( - Func onFirstAsync, - Func onSecondAsync) - => - InnerOnValueAsync( - onFirstAsync ?? throw new ArgumentNullException(nameof(onFirstAsync)), - onSecondAsync ?? throw new ArgumentNullException(nameof(onSecondAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.TUnit.cs deleted file mode 100644 index 096b97e5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.TUnit.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnFirst( - Func handler) - => - InnerOnFirst( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnFirstAsync( - Func> handlerAsync) - => - InnerOnFirstAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnFirstValueAsync( - Func> handlerAsync) - => - InnerOnFirstValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.Unit.cs deleted file mode 100644 index 6f033c39..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.Unit.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnFirst( - Func handler) - => - InnerOnFirst( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnFirstAsync( - Func> handlerAsync) - => - InnerOnFirstAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnFirstValueAsync( - Func> handlerAsync) - => - InnerOnFirstValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.cs deleted file mode 100644 index 5925e5de..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnFirst.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnFirst( - Action handler) - => - InnerOnFirst( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnFirstAsync( - Func handlerAsync) - => - InnerOnFirstAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnFirstValueAsync( - Func handlerAsync) - => - InnerOnFirstValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.TUnit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.TUnit.cs deleted file mode 100644 index 570e43e5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.TUnit.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnSecond( - Func handler) - => - InnerOnSecond( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnSecondAsync( - Func> handlerAsync) - => - InnerOnSecondAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnSecondValueAsync( - Func> handlerAsync) - => - InnerOnSecondValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.Unit.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.Unit.cs deleted file mode 100644 index 43984932..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.Unit.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnSecond( - Func handler) - => - InnerOnSecond( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnSecondAsync( - Func> handlerAsync) - => - InnerOnSecondAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnSecondValueAsync( - Func> handlerAsync) - => - InnerOnSecondValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.cs deleted file mode 100644 index de987194..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OnSecond.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - // TODO: Add the tests and open the methods - internal TaggedUnion OnSecond( - Action handler) - => - InnerOnSecond( - handler ?? throw new ArgumentNullException(nameof(handler))); - - internal Task> OnSecondAsync( - Func handlerAsync) - => - InnerOnSecondAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); - - internal ValueTask> OnSecondValueAsync( - Func handlerAsync) - => - InnerOnSecondValueAsync( - handlerAsync ?? throw new ArgumentNullException(nameof(handlerAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Or.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Or.cs deleted file mode 100644 index d2fb9ba5..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.Or.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading.Tasks; - -namespace System; - -partial struct TaggedUnion -{ - public TaggedUnion Or( - Func> otherFactory) - => - InnerOr( - otherFactory ?? throw new ArgumentNullException(nameof(otherFactory))); - - public Task> OrAsync( - Func>> otherFactoryAsync) - => - InnerOrAsync( - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); - - public ValueTask> OrValueAsync( - Func>> otherFactoryAsync) - => - InnerOrValueAsync( - otherFactoryAsync ?? throw new ArgumentNullException(nameof(otherFactoryAsync))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.First.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.First.cs deleted file mode 100644 index e1473b71..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.First.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public TFirst FirstOrThrow() - => - InnerFirstOrThrow(InnerCreateExpectedFirstException); - - public TFirst FirstOrThrow(Func exceptionFactory) - => - InnerFirstOrThrow(exceptionFactory ?? throw new ArgumentNullException(nameof(exceptionFactory))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.Second.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.Second.cs deleted file mode 100644 index b00c2f23..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.OrThrow.Second.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public TSecond SecondOrThrow() - => - InnerSecondOrThrow(InnerCreateExpectedSecondException); - - public TSecond SecondOrThrow(Func exceptionFactory) - => - InnerSecondOrThrow(exceptionFactory ?? throw new ArgumentNullException(nameof(exceptionFactory))); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.ToString.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.ToString.cs deleted file mode 100644 index cb976a4f..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.ToString.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace System; - -partial struct TaggedUnion -{ - public override string ToString() - => - InnerToString(); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.cs deleted file mode 100644 index e0ae7ea1..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.T/TaggedUnion.T.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace System; - -[Obsolete("TaggedUnion is obsolete and will be removed in Taggeds v3.0.", error: false)] -public readonly partial struct TaggedUnion : IEquatable> -{ - private readonly Tag tag; - - private readonly TFirst first; - - private readonly TSecond second; - - public bool IsNone - => - tag is Tag.None; - - public bool IsNotNone - => - tag is not Tag.None; - - public bool IsFirst - => - tag is Tag.First; - - public bool IsSecond - => - tag is Tag.Second; - - // TODO: Remove the property in v3.0 - [Obsolete("This property is obsolete. Call IsNotNone instead.", error: true)] - public bool IsInitialized - => - tag is not Tag.None; -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion.csproj b/src/core-taggeds-union/TaggedUnion/TaggedUnion.csproj deleted file mode 100644 index 6e328b79..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - - net6.0;net7.0;net8.0 - latest - disable - enable - true - true - true - LICENSE - README.md - https://github.com/pfpack/pfpack-core-taggeds - https://github.com/pfpack/pfpack-core-taggeds - pfpack - Andrei Sergeev, Pavel Moskovoy - Copyright © 2020-2024 Andrei Sergeev, Pavel Moskovoy - PrimeFuncPack Core.TaggedUnion is a core library for .NET consisting of Tagged Union targeted for use in functional programming. - System - PrimeFuncPack.Core.TaggedUnion - 2.1.0-preview.3 - - - - - True - - - - True - - - - - - - - - diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.Equality.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.Equality.cs deleted file mode 100644 index b5e5482b..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.Equality.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace System; - -partial class TaggedUnion -{ - public static bool Equals( - TaggedUnion left, TaggedUnion right) - => - left.Equals(right); -} diff --git a/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.cs b/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.cs deleted file mode 100644 index d5097094..00000000 --- a/src/core-taggeds-union/TaggedUnion/TaggedUnion/TaggedUnion.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace System; - -[Obsolete("TaggedUnion is obsolete and will be removed in Taggeds v3.0.", error: false)] -public static partial class TaggedUnion -{ -} diff --git a/src/core-taggeds/Taggeds.Tests.Old/Taggeds.Tests.Old.csproj b/src/core-taggeds/Taggeds.Tests.Old/Taggeds.Tests.Old.csproj index f986cf76..120778df 100644 --- a/src/core-taggeds/Taggeds.Tests.Old/Taggeds.Tests.Old.csproj +++ b/src/core-taggeds/Taggeds.Tests.Old/Taggeds.Tests.Old.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,14 +16,17 @@ - - - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Optional.ToTaggedUnion.cs b/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Optional.ToTaggedUnion.cs deleted file mode 100644 index 5f2bed61..00000000 --- a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Optional.ToTaggedUnion.cs +++ /dev/null @@ -1,31 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedsExtensionsTests -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void Optional_ToTaggedUnion_OptionalIsPresent_ExpectActualIsFirst( - object? sourceValue) - { - var optional = Optional.Present(sourceValue); - var actual = optional.ToTaggedUnion(); - - var expected = TaggedUnion.First(sourceValue); - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void Optional_ToTaggedUnion_OptionalIsAbsent_ExpectActualIsSecond() - { - var optional = Optional.Absent(); - var actual = optional.ToTaggedUnion(); - - var expected = TaggedUnion.Second(Unit.Value); - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Result.ToTaggedUnion.cs b/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Result.ToTaggedUnion.cs deleted file mode 100644 index 0d11f8af..00000000 --- a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.Result.ToTaggedUnion.cs +++ /dev/null @@ -1,56 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionResultExtensions -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.FailureDefaultTestSource))] - public void Result_ToTaggedUnion_SourceResultIsDefault_ExpectUnionSecondOfDefaultValue( - Result sourceResult) - { - var actual = sourceResult.ToTaggedUnion(); - var expected = TaggedUnion.Second(default); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.FailureSomeTextStructTypeTestSource))] - public void Result_ToTaggedUnion_SourceResultIsFailure_ExpectUnionSecondOfSourceFailureValue( - Result sourceResult) - { - var actual = sourceResult.ToTaggedUnion(); - var expected = TaggedUnion.Second(SomeTextStructType); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.SuccessNullTestSource))] - public void Result_ToTaggedUnion_SourceResultIsSuccessAndSourceValueIsNull_ExpectUnionFirstOfNullValue( - Result sourceResult) - { - var actual = sourceResult.ToTaggedUnion(); - var expected = TaggedUnion.First(null); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.SuccessPlusFifteenIdRefTypeTestSource))] - public void Result_ToTaggedUnion_SourceResultIsSuccessAndSourceValueIsNotNull_ExpectUnionFirstOfSourceSuccessValue( - Result sourceResult) - { - var actual = sourceResult.ToTaggedUnion(); - var expected = TaggedUnion.First(PlusFifteenIdRefType); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToOptional.cs b/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToOptional.cs deleted file mode 100644 index 8a832eef..00000000 --- a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToOptional.cs +++ /dev/null @@ -1,42 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedsExtensionsTests -{ - [Obsolete] - [Test] - [TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.ObjectNullableTestSource))] - public void TaggedUnion_ToOptional_UnionIsFirst_ExpectPresent( - object? sourceValue) - { - var union = TaggedUnion.First(sourceValue); - var actual = union.ToOptional(); - - var expected = Optional.Present(sourceValue); - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void TaggedUnion_ToOptional_UnionIsDefault_ExpectAbsent() - { - var union = default(TaggedUnion); - var actual = union.ToOptional(); - - var expected = Optional.Absent(); - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void TaggedUnion_ToOptional_UnionIsSecond_ExpectAbsent() - { - var union = TaggedUnion.Second(Unit.Value); - var actual = union.ToOptional(); - - var expected = Optional.Absent(); - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToResult.cs b/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToResult.cs deleted file mode 100644 index cbdb6247..00000000 --- a/src/core-taggeds/Taggeds.Tests.Old/TaggedsExtensionsTests/Obsolete.TaggedUnion.ToResult.cs +++ /dev/null @@ -1,61 +0,0 @@ -using PrimeFuncPack.UnitTest; -using System; -using static PrimeFuncPack.UnitTest.TestData; - -namespace PrimeFuncPack.Core.Tests; - -partial class TaggedUnionResultExtensions -{ - [Obsolete] - [Test] - public void TaggedUnion_ToResult_SourceUnionIsDefault_ExpectDefaultResult() - { - var sourceUnion = default(TaggedUnion); - - var actual = sourceUnion.ToResult(); - var expected = default(Result); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void TaggedUnion_ToResult_SourceUnionIsSecond_ExpectFailureResult() - { - var sourceValue = new SomeError(MinusFifteen); - var sourceUnion = TaggedUnion.Second(sourceValue); - - var actual = sourceUnion.ToResult(); - var expected = Result.Failure(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void TaggedUnion_ToResult_SourceUnionIsFirstAndSourceValueIsNull_ExpectSuccessResultOfNullValue() - { - var sourceUnion = TaggedUnion.First(null); - - var actual = sourceUnion.ToResult(); - var expected = Result.Success(null); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Obsolete] - [Test] - public void TaggedUnion_ToResult_SourceUnionIsFirstAndSourceValueIsNotNull_ExpectSuccessResultOfSourceValue() - { - var sourceValue = new SomeRecord - { - Text = SomeString - }; - var sourceUnion = TaggedUnion.First(sourceValue); - - var actual = sourceUnion.ToResult(); - var expected = Result.Success(sourceValue); - - Assert.That(actual, Is.EqualTo(expected)); - } -} diff --git a/src/core-taggeds/Taggeds.Tests/Taggeds.Tests.csproj b/src/core-taggeds/Taggeds.Tests/Taggeds.Tests.csproj index 8dea4d2e..d0d0f6ef 100644 --- a/src/core-taggeds/Taggeds.Tests/Taggeds.Tests.csproj +++ b/src/core-taggeds/Taggeds.Tests/Taggeds.Tests.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -16,10 +16,13 @@ - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/core-taggeds/Taggeds/Taggeds.csproj b/src/core-taggeds/Taggeds/Taggeds.csproj index 20ba6827..23f8f0f9 100644 --- a/src/core-taggeds/Taggeds/Taggeds.csproj +++ b/src/core-taggeds/Taggeds/Taggeds.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net8.0 latest disable enable @@ -18,7 +18,7 @@ PrimeFuncPack Core.Taggeds is a core pack for .NET consisting of fundamental tagged types targeted for use in functional programming: Optional and Result monads, Tagged Union, as well as the convert extensions. System PrimeFuncPack.Core.Taggeds - 2.2.0-preview.9 + 3.0-preview.1 @@ -33,11 +33,10 @@ - - - - - + + + + diff --git a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Optional.ToTaggedUnion.cs b/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Optional.ToTaggedUnion.cs deleted file mode 100644 index 09ff9522..00000000 --- a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Optional.ToTaggedUnion.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace System; - -partial class TaggedsExtensions -{ - [Obsolete("TaggedUnion and this method are obsolete and will be removed in Taggeds v3.0.", error: false)] - public static TaggedUnion ToTaggedUnion(this Optional optional) - => - optional.Fold>( - value => new(value), - static () => new(default(Unit))); -} diff --git a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Result.ToTaggedUnion.cs b/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Result.ToTaggedUnion.cs deleted file mode 100644 index 68892a72..00000000 --- a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.Result.ToTaggedUnion.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace System; - -partial class TaggedsExtensions -{ - [Obsolete("TaggedUnion and this method are obsolete and will be removed in Taggeds v3.0.", error: false)] - public static TaggedUnion ToTaggedUnion( - this Result result) - where TFailure : struct - => - result.Fold>( - success => new(success), - failure => new(failure)); -} diff --git a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToOptional.cs b/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToOptional.cs deleted file mode 100644 index 9881983b..00000000 --- a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToOptional.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace System; - -partial class TaggedsExtensions -{ - [Obsolete("TaggedUnion and this method are obsolete and will be removed in Taggeds v3.0.", error: false)] - public static Optional ToOptional(this TaggedUnion union) - => - union.Fold>( - value => new(value), - static _ => default); -} diff --git a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToResult.cs b/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToResult.cs deleted file mode 100644 index 3a7bf604..00000000 --- a/src/core-taggeds/Taggeds/TaggedsExtensions/Obsolete.TaggedUnion.ToResult.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace System; - -partial class TaggedsExtensions -{ - [Obsolete("TaggedUnion and this method are obsolete and will be removed in Taggeds v3.0.", error: false)] - public static Result ToResult( - this TaggedUnion union) - where TFailure : struct - => - union.Fold>( - success => new(success), - failure => new(failure)); -} From 07187f36cc82bf9a4f6857880e739a981bc0c350 Mon Sep 17 00:00:00 2001 From: Andrei Sergeev Date: Sat, 21 Sep 2024 22:50:24 +0400 Subject: [PATCH 2/2] Update gitignore to the latest --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 426d76dd..8a30d258 100644 --- a/.gitignore +++ b/.gitignore @@ -301,7 +301,7 @@ node_modules/ *.dsw *.dsp -# Visual Studio 6 technical files +# Visual Studio 6 technical files *.ncb *.aps