Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/2.2.0-preview.9_tagged-union #138

Merged
merged 4 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ jobs:
- name: Pack TaggedUnion
run: dotnet pack ./src/*/*/TaggedUnion.csproj --no-restore -o ~/nuget -c Release

- name: Restore TaggedUnion.Tests
run: dotnet restore ./src/*/*/TaggedUnion.Tests.csproj
- name: Restore TaggedUnion.Tests.Old
run: dotnet restore ./src/*/*/TaggedUnion.Tests.Old.csproj

- name: Test TaggedUnion.Tests
run: dotnet test ./src/*/*/TaggedUnion.Tests.csproj --no-restore -c Release
- name: Test TaggedUnion.Tests.Old
run: dotnet test ./src/*/*/TaggedUnion.Tests.Old.csproj --no-restore -c Release

# Result

Expand Down
2 changes: 2 additions & 0 deletions src/core-taggeds-union/TaggedUnion.Tests.Old/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using NUnit.Framework;
global using NUnit.Framework.Legacy;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;
using static PrimeFuncPack.UnitTest.TestData;

Expand All @@ -13,7 +12,7 @@ public void OrInitialize_OtherFactoryIsNull_ExpectArgumentNullException(
TaggedUnion<RefType, StructType> source)
{
var ex = Assert.Throws<ArgumentNullException>(() => _ = TaggedUnionExtensions.OrInitialize(source, null!));
Assert.AreEqual("otherFactory", ex!.ParamName);
ClassicAssert.AreEqual("otherFactory", ex!.ParamName);
}

[Test]
Expand All @@ -23,7 +22,7 @@ public void OrInitialize_SourceIsFirst_ExpectSource()
var other = TaggedUnion<object, StructType>.Second(SomeTextStructType);

var actual = TaggedUnionExtensions.OrInitialize(source, () => other);
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -33,7 +32,7 @@ public void OrInitialize_SourceIsSecond_ExpectSource()
var other = TaggedUnion<object, RefType>.Second(PlusFifteenIdRefType);

var actual = TaggedUnionExtensions.OrInitialize(source, () => other);
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -43,6 +42,6 @@ public void OrInitialize_SourceIsDefault_ExpectOther()
var other = TaggedUnion<object, StructType>.First(new object());

var actual = TaggedUnionExtensions.OrInitialize(source, () => other);
Assert.AreEqual(other, actual);
ClassicAssert.AreEqual(other, actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;
Expand All @@ -14,7 +13,7 @@ public void OrInitializeAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullExceptio
TaggedUnion<RefType, StructType> source)
{
var ex = Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await TaggedUnionExtensions.OrInitializeAsync(source, null!));
Assert.AreEqual("otherFactoryAsync", ex!.ParamName);
ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName);
}

[Test]
Expand All @@ -24,7 +23,7 @@ public async Task OrInitializeAsync_SourceIsFirst_ExpectSource()
var other = TaggedUnion<RefType?, StructType>.First(ZeroIdRefType);

var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other));
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -34,7 +33,7 @@ public async Task OrInitializeAsync_SourceIsSecond_ExpectSource()
var other = default(TaggedUnion<object, StructType>);

var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other));
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -44,6 +43,6 @@ public async Task OrInitializeAsync_SourceIsDefault_ExpectOther()
var other = TaggedUnion<int, RefType>.Second(new RefType());

var actual = await TaggedUnionExtensions.OrInitializeAsync(source, () => Task.FromResult(other));
Assert.AreEqual(other, actual);
ClassicAssert.AreEqual(other, actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;
Expand All @@ -14,7 +13,7 @@ public void OrInitializeValueAsync_OtherFactoryAsyncIsNull_ExpectArgumentNullExc
TaggedUnion<RefType, StructType> source)
{
var ex = Assert.ThrowsAsync<ArgumentNullException>(async () => _ = await TaggedUnionExtensions.OrInitializeValueAsync(source, null!));
Assert.AreEqual("otherFactoryAsync", ex!.ParamName);
ClassicAssert.AreEqual("otherFactoryAsync", ex!.ParamName);
}

[Test]
Expand All @@ -24,7 +23,7 @@ public async Task OrInitializeValueAsync_SourceIsFirst_ExpectSource()
var other = default(TaggedUnion<StructType, DateTime>);

var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other));
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -34,7 +33,7 @@ public async Task OrInitializeValueAsync_SourceIsSecond_ExpectSource()
var other = TaggedUnion<object, StructType>.Second(SomeTextStructType);

var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other));
Assert.AreEqual(source, actual);
ClassicAssert.AreEqual(source, actual);
}

[Test]
Expand All @@ -44,6 +43,6 @@ public async Task OrInitializeValueAsync_SourceIsDefault_ExpectOther()
var other = TaggedUnion<RefType, object>.First(MinusFifteenIdRefType);

var actual = await TaggedUnionExtensions.OrInitializeValueAsync(source, () => ValueTask.FromResult(other));
Assert.AreEqual(other, actual);
ClassicAssert.AreEqual(other, actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;
using static PrimeFuncPack.UnitTest.TestData;

Expand All @@ -14,7 +13,7 @@ public void Equals_UnionAIsDefaultAndUnionBIsDefault_ExpectTrue()
var unionB = new TaggedUnion<StructType, RefType>();

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -26,7 +25,7 @@ public void Equals_UnionAFirstValueEqualsUnionBFirstValue_ExpectTrue(
var unionB = TaggedUnion<object?, StructType>.First(sourceValue);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -47,7 +46,7 @@ public void Equals_UnionASecondValueEqualsUnionBSecondValue_ExpectTrue()
var unionB = (TaggedUnion<RefType, StructType>)bValue;

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -57,7 +56,7 @@ public void Equals_UnionAIsDefaultAndUnionBIsFirst_ExpectFalse()
var unionB = TaggedUnion<RefType?, StructType>.First(null);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -67,7 +66,7 @@ public void Equals_UnionAIsDefaultAndUnionBIsSecond_ExpectFalse()
var unionB = TaggedUnion<object, StructType>.Second(default);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -77,7 +76,7 @@ public void Equals_UnionAIsFirstAndUnionBIsDefault_ExpectFalse()
var unionB = default(TaggedUnion<RefType, StructType>);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -87,7 +86,7 @@ public void Equals_UnionAIsFirstAndUnionBIsSecond_ExpectFalse()
var unionB = TaggedUnion<StructType, StructType>.Second(SomeTextStructType);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -97,7 +96,7 @@ public void Equals_UnionAIsSecondAndUnionBIsDefault_ExpectFalse()
var unionB = default(TaggedUnion<StructType, RefType>);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -107,7 +106,7 @@ public void Equals_UnionAIsSecondAndUnionBIsFirst_ExpectFalse()
var unionB = TaggedUnion<RefType, RefType>.First(ZeroIdRefType);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -128,7 +127,7 @@ public void Equals_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectFalse()
var unionB = TaggedUnion<RefType, StructType?>.First(bValue);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -147,6 +146,6 @@ public void Equals_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectFalse()
var unionB = TaggedUnion<RefType, StructType>.Second(bValue);

var actual = TaggedUnion.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest;
using System;
using static PrimeFuncPack.UnitTest.TestData;

Expand All @@ -14,7 +13,7 @@ public void EqualsStatic_UnionAIsDefaultAndUnionBIsDefault_ExpectTrue()
var unionB = new TaggedUnion<RefType, StructType>();

var actual = TaggedUnion<RefType, StructType>.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -33,7 +32,7 @@ public void EqualsStatic_UnionAFirstValueEqualsUnionBFirstValue_ExpectTrue()
var unionB = (TaggedUnion<StructType, RefType?>)bValue;

var actual = TaggedUnion<StructType, RefType?>.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -43,7 +42,7 @@ public void EqualsStatic_UnionASecondValueEqualsUnionBSecondValue_ExpectTrue()
var unionB = (TaggedUnion<StructType, RefType?>)MinusFifteenIdRefType;

var actual = TaggedUnion<StructType, RefType?>.Equals(unionA, unionB);
Assert.True(actual);
ClassicAssert.True(actual);
}

[Test]
Expand All @@ -53,7 +52,7 @@ public void EqualsStatic_UnionAIsDefaultAndUnionBIsFirst_ExpectFalse()
var unionB = TaggedUnion<StructType, RefType>.First(default);

var actual = TaggedUnion<StructType, RefType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -63,7 +62,7 @@ public void EqualsStatic_UnionAIsDefaultAndUnionBIsSecond_ExpectFalse()
var unionB = TaggedUnion<StructType, RefType?>.Second(null);

var actual = TaggedUnion<StructType, RefType?>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -73,7 +72,7 @@ public void EqualsStatic_UnionAIsFirstAndUnionBIsDefault_ExpectFalse()
var unionB = default(TaggedUnion<StructType, RefType>);

var actual = TaggedUnion<StructType, RefType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -83,7 +82,7 @@ public void EqualsStatic_UnionAIsFirstAndUnionBIsSecond_ExpectFalse()
var unionB = TaggedUnion<RefType, RefType>.Second(PlusFifteenIdRefType);

var actual = TaggedUnion<RefType, RefType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -93,7 +92,7 @@ public void EqualsStatic_UnionAIsSecondAndUnionBIsDefault_ExpectFalse()
var unionB = default(TaggedUnion<StructType, RefType>);

var actual = TaggedUnion<StructType, RefType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -103,7 +102,7 @@ public void EqualsStatic_UnionAIsSecondAndUnionBIsFirst_ExpectFalse()
var unionB = TaggedUnion<StructType, StructType>.First(SomeTextStructType);

var actual = TaggedUnion<StructType, StructType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -124,7 +123,7 @@ public void EqualsStatic_UnionAFirstValueIsNotEqualUnionBFirstValue_ExpectFalse(
var unionB = TaggedUnion<RefType, StructType?>.First(bValue);

var actual = TaggedUnion<RefType, StructType?>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}

[Test]
Expand All @@ -143,6 +142,6 @@ public void EqualsStatic_UnionASecondValueIsNotEqualUnionBSecondValue_ExpectFals
var unionB = TaggedUnion<RefType, StructType>.Second(bValue);

var actual = TaggedUnion<RefType, StructType>.Equals(unionA, unionB);
Assert.False(actual);
ClassicAssert.False(actual);
}
}
Loading