diff --git a/Directory.Packages.props b/Directory.Packages.props
index b0bf6262..4a017103 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -41,8 +41,8 @@
-
-
+
+
diff --git a/test/Nerdbank.MessagePack.Tests/ArraysOfPrimitivesTests.cs b/test/Nerdbank.MessagePack.TUnit/ArraysOfPrimitivesTests.cs
similarity index 60%
rename from test/Nerdbank.MessagePack.Tests/ArraysOfPrimitivesTests.cs
rename to test/Nerdbank.MessagePack.TUnit/ArraysOfPrimitivesTests.cs
index 77773f9d..faecbe6c 100644
--- a/test/Nerdbank.MessagePack.Tests/ArraysOfPrimitivesTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/ArraysOfPrimitivesTests.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Numerics;
-using System.Reflection;
public partial class ArraysOfPrimitivesTests : MessagePackSerializerTestBase
{
@@ -12,8 +11,8 @@ public partial class ArraysOfPrimitivesTests : MessagePackSerializerTestBase
private static readonly Random Random = new Random();
#endif
- [Theory, PairwiseData]
- public void BoolArray([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(byte))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void BoolArray(int length)
{
bool[]? values = null;
if (length >= 0)
@@ -26,8 +25,8 @@ public void BoolArray([CombinatorialMemberData(nameof(GetInterestingLengths), ty
this.Roundtrip(values);
}
- [Theory, PairwiseData]
- public void Boolean([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(byte))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Boolean(int length)
{
bool[]? values = null;
if (length >= 0)
@@ -40,40 +39,40 @@ public void Boolean([CombinatorialMemberData(nameof(GetInterestingLengths), type
this.Roundtrip, Witness>(values);
}
- [Theory, PairwiseData]
- public void Int8([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(sbyte))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Int8(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void Int16([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(short))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Int16(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void Int32([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(int))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Int32(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void Int64([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(long))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Int64(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void UInt8([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(byte))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void UInt8(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void UInt16([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(ushort))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void UInt16(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void UInt32([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(uint))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void UInt32(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void UInt64([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(ulong))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void UInt64(int length)
=> this.Roundtrip, Witness>(GetRandomValues(length));
- [Theory, PairwiseData]
- public void Single([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(float))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Single(int length)
{
float[]? values = null;
if (length >= 0)
@@ -92,8 +91,8 @@ public void Single([CombinatorialMemberData(nameof(GetInterestingLengths), typeo
this.Roundtrip, Witness>(values);
}
- [Theory, PairwiseData]
- public void Double([CombinatorialMemberData(nameof(GetInterestingLengths), typeof(double))] int length)
+ [Test, MethodDataSource(typeof(GetInterestingLengthsHelper), nameof(GetInterestingLengthsHelper<>.Helper))]
+ public void Double(int length)
{
double[]? values = null;
if (length >= 0)
@@ -108,7 +107,7 @@ public void Double([CombinatorialMemberData(nameof(GetInterestingLengths), typeo
this.Roundtrip, Witness>(values);
}
- [Fact]
+ [Test]
public void LargeEnumerableOfInt()
{
// A very large enumerable so that it exceeds any default buffer sizes.
@@ -138,13 +137,14 @@ public void LargeEnumerableOfInt()
return values;
}
- private static int[] GetInterestingLengths(Type type) => (int[])typeof(ArraysOfPrimitivesTests).GetMethod(nameof(GetInterestingLengthsHelper), BindingFlags.NonPublic | BindingFlags.Static)!.MakeGenericMethod(type).Invoke(null, null)!;
-
+ public static class GetInterestingLengthsHelper
+ {
#if NET
- private static int[] GetInterestingLengthsHelper() => [-1, 0, 4, Vector.Count - 1, Vector.Count, Vector.Count + 1, (Vector.Count * 2) + 2, 10_000];
+ public static int[] Helper() => [-1, 0, 4, Vector.Count - 1, Vector.Count, Vector.Count + 1, (Vector.Count * 2) + 2, 10_000];
#else
- private static int[] GetInterestingLengthsHelper() => [-1, 0, 4, 100, 10_000];
+ public static int[] Helper() => [-1, 0, 4, 100, 10_000];
#endif
+ }
[GenerateShapeFor]
[GenerateShapeFor>]
diff --git a/test/Nerdbank.MessagePack.Tests/AsyncSerializationTests.cs b/test/Nerdbank.MessagePack.TUnit/AsyncSerializationTests.cs
similarity index 93%
rename from test/Nerdbank.MessagePack.Tests/AsyncSerializationTests.cs
rename to test/Nerdbank.MessagePack.TUnit/AsyncSerializationTests.cs
index 05a0594e..aaeb3a91 100644
--- a/test/Nerdbank.MessagePack.Tests/AsyncSerializationTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/AsyncSerializationTests.cs
@@ -1,18 +1,18 @@
// Copyright (c) Andrew Arnott. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-[Trait("AsyncSerialization", "true")]
+[Property("AsyncSerialization", "true")]
public partial class AsyncSerializationTests : MessagePackSerializerTestBase
{
private static readonly ReadOnlyMemory BigDataBlob = Enumerable.Range(0, 100).Select(n => (byte)(n % 256)).ToArray();
- [Fact]
+ [Test]
public async Task RoundtripPoco() => await this.AssertRoundtripAsync(new Poco(1, 2));
- [Fact]
+ [Test]
public async Task RoundtripPocoWithDefaultCtor() => await this.AssertRoundtripAsync(new PocoWithDefaultCtor { X = 1, Y = 2 });
- [Fact]
+ [Test]
public async Task PocoDictionary()
{
DictionaryOfPocos value = new(new Dictionary
@@ -25,7 +25,7 @@ public async Task PocoDictionary()
await this.AssertRoundtripAsync(value);
}
- [Fact]
+ [Test]
public async Task PrimitivesDictionary()
{
DictionaryOfPrimitives value = new(new Dictionary
@@ -38,13 +38,13 @@ public async Task PrimitivesDictionary()
await this.AssertRoundtripAsync(value);
}
- [Fact]
+ [Test]
public async Task LargeArray() => await this.AssertRoundtripAsync(new ArrayOfPocos(Enumerable.Range(0, 1000).Select(i => new Poco(i, i)).ToArray()));
///
/// Verifies that the array converter can handle async serialization when its elements are not async capable.
///
- [Fact]
+ [Test]
public async Task LargeArrayWithBigElements()
{
this.Serializer = this.Serializer with { Converters = [.. this.Serializer.Converters, new PocoNonAsyncConverter()] };
@@ -52,40 +52,40 @@ public async Task LargeArrayWithBigElements()
await this.AssertRoundtripAsync(new ArrayOfPocos(Enumerable.Range(0, 1000).Select(i => new Poco(i, i) { DataBlob = BigDataBlob }).ToArray()));
}
- [Fact]
+ [Test]
public async Task LargeList() => await this.AssertRoundtripAsync(new ListOfPocos(Enumerable.Range(0, 1000).Select(i => new Poco(i, i)).ToList()));
- [Fact]
+ [Test]
public async Task LargeImmutableArray() => await this.AssertRoundtripAsync(new ImmutableArrayOfPocos(Enumerable.Range(0, 1000).Select(i => new Poco(i, i)).ToImmutableArray()));
- [Fact]
+ [Test]
public async Task Null_Array() => await this.AssertRoundtripAsync(new ArrayOfPocos(null));
- [Fact]
+ [Test]
public async Task Null() => await this.AssertRoundtripAsync(null);
- [Fact]
+ [Test]
public async Task ArrayOfInts() => await this.AssertRoundtripAsync(new ArrayOfPrimitives([1, 2, 3]));
- [Fact]
+ [Test]
public async Task ObjectAsArrayOfValues() => await this.AssertRoundtripAsync(new PocoAsArray(42));
- [Fact]
+ [Test]
public async Task ObjectAsArrayOfValues_Null() => await this.AssertRoundtripAsync(null);
- [Fact]
+ [Test]
public async Task ObjectAsArrayOfValues_DefaultCtor() => await this.AssertRoundtripAsync(new PocoAsArrayWithDefaultCtor { Value = 42 });
- [Fact]
+ [Test]
public async Task ObjectAsArrayOfValues_DefaultCtor_Null() => await this.AssertRoundtripAsync(null);
- [Fact]
+ [Test]
public async Task WithPreBuffering()
{
SpecialRecordConverter converter = new();
this.Serializer = this.Serializer with { Converters = [converter] };
var msgpack = new ReadOnlySequence(
- this.Serializer.Serialize(new SpecialRecord { Property = 446 }, TestContext.Current.CancellationToken));
+ this.Serializer.Serialize(new SpecialRecord { Property = 446 }, this.TimeoutToken));
// Verify that with a sufficiently low async buffer, the async paths are taken.
this.Serializer = new()
@@ -93,7 +93,7 @@ public async Task WithPreBuffering()
MaxAsyncBuffer = 1,
Converters = [converter],
};
- await this.Serializer.DeserializeAsync(new FragmentedPipeReader(msgpack), TestContext.Current.CancellationToken);
+ await this.Serializer.DeserializeAsync(new FragmentedPipeReader(msgpack), this.TimeoutToken);
Assert.Equal(1, converter.AsyncDeserializationCounter);
// Verify that with a sufficiently high async buffer, the sync paths are taken.
@@ -103,31 +103,31 @@ public async Task WithPreBuffering()
MaxAsyncBuffer = 15,
Converters = [converter],
};
- await this.Serializer.DeserializeAsync(new FragmentedPipeReader(msgpack), TestContext.Current.CancellationToken);
+ await this.Serializer.DeserializeAsync(new FragmentedPipeReader(msgpack), this.TimeoutToken);
Assert.Equal(0, converter.AsyncDeserializationCounter);
}
- [Fact]
+ [Test]
public async Task DecodeLargeString()
{
string expected = new string('a', 100 * 1024);
- ReadOnlySequence msgpack = new(this.Serializer.Serialize(expected, TestContext.Current.CancellationToken));
+ ReadOnlySequence msgpack = new(this.Serializer.Serialize(expected, this.TimeoutToken));
FragmentedPipeReader pipeReader = new(msgpack, msgpack.GetPosition(0), msgpack.GetPosition(1), msgpack.GetPosition(512), msgpack.GetPosition(6000), msgpack.GetPosition(32 * 1024));
- string? actual = await this.Serializer.DeserializeAsync(pipeReader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), TestContext.Current.CancellationToken);
+ string? actual = await this.Serializer.DeserializeAsync(pipeReader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), this.TimeoutToken);
Assert.Equal(expected, actual);
}
- [Fact]
+ [Test]
public async Task DecodeEmptyString()
{
string expected = string.Empty;
- ReadOnlySequence msgpack = new(this.Serializer.Serialize(expected, TestContext.Current.CancellationToken));
+ ReadOnlySequence msgpack = new(this.Serializer.Serialize(expected, this.TimeoutToken));
FragmentedPipeReader pipeReader = new(msgpack, msgpack.GetPosition(0));
- string? actual = await this.Serializer.DeserializeAsync(pipeReader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), TestContext.Current.CancellationToken);
+ string? actual = await this.Serializer.DeserializeAsync(pipeReader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), this.TimeoutToken);
Assert.Equal(expected, actual);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task DeserializeAsyncAdvancesPipeReader(bool forceAsync)
{
this.Serializer = this.Serializer with { MaxAsyncBuffer = forceAsync ? 0 : 1024 };
@@ -140,11 +140,11 @@ public async Task DeserializeAsyncAdvancesPipeReader(bool forceAsync)
PipeReader reader = PipeReader.Create(sequence);
// Deserialize a value. It should advance the reader exactly across the msgpack structure.
- int number = await this.Serializer.DeserializeAsync(reader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), TestContext.Current.CancellationToken);
+ int number = await this.Serializer.DeserializeAsync(reader, Witness.GeneratedTypeShapeProvider.GetTypeShapeOrThrow(), this.TimeoutToken);
Assert.Equal(42, number);
// Verify that the reader is now positioned at the next byte.
- ReadResult readResult = await reader.ReadAsync(TestContext.Current.CancellationToken);
+ ReadResult readResult = await reader.ReadAsync(this.TimeoutToken);
Assert.True(readResult.IsCompleted);
Assert.Equal("a"u8, readResult.Buffer.ToArray());
}
diff --git a/test/Nerdbank.MessagePack.TUnit/BuiltInConverterTests.cs b/test/Nerdbank.MessagePack.TUnit/BuiltInConverterTests.cs
new file mode 100644
index 00000000..3229fd35
--- /dev/null
+++ b/test/Nerdbank.MessagePack.TUnit/BuiltInConverterTests.cs
@@ -0,0 +1,472 @@
+// Copyright (c) Andrew Arnott. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Drawing;
+using System.Globalization;
+using System.Numerics;
+using System.Runtime.InteropServices;
+using System.Text;
+
+public partial class BuiltInConverterTests : MessagePackSerializerTestBase
+{
+ private const string BadGuidFormatErrorMessage = "Not a recognized GUID format.";
+
+ [Test]
+ public void SystemDrawingColor() => this.AssertRoundtrip(Color.FromArgb(1, 2, 3, 4));
+
+ [Test]
+ public void SystemDrawingPoint() => this.AssertRoundtrip(new Point(1, 1));
+
+ [Test]
+ public void ImmutableDictionary() => this.AssertRoundtrip(new HasImmutableDictionary() { Map = ImmutableDictionary.Empty.Add("a", 1) });
+
+#if NET
+
+ [Test]
+ public void Int128()
+ {
+ this.AssertRoundtrip(new HasInt128(0));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasInt128(long.MaxValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasInt128(long.MinValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasInt128(new Int128(1, 2)));
+ this.AssertType(MessagePackType.Extension);
+
+ this.AssertRoundtrip(new HasInt128(System.Int128.MaxValue));
+ this.AssertType(MessagePackType.Extension);
+
+ this.AssertRoundtrip(new HasInt128(System.Int128.MinValue));
+ this.AssertType(MessagePackType.Extension);
+ }
+
+ ///
+ /// Verifies that we can read values that use the Bin header, which is what MessagePack-CSharp's "native" formatter uses.
+ ///
+ ///
+ /// Note that while our mandates big endian encoding to match msgpack conventions,
+ /// The Bin encoding used by MessagePack-CSharp uses little-endian encoding.
+ ///
+ [Test]
+ public void Int128_FromBin()
+ {
+ Int128 value = new(1, 2);
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasInt128.Value));
+ writer.WriteBinHeader(128 / 8);
+ Span byteSpan = writer.GetSpan(128 / 8);
+ Assert.True(((IBinaryInteger)value).TryWriteLittleEndian(byteSpan, out int written));
+ writer.Advance(written);
+ writer.Flush();
+
+ Assert.Equal(value, this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+ [Test]
+ public void UInt128()
+ {
+ this.AssertRoundtrip(new HasUInt128(0));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasInt128(ulong.MaxValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasUInt128(new UInt128(1, 2)));
+ this.AssertType(MessagePackType.Extension);
+
+ this.AssertRoundtrip(new HasUInt128(System.UInt128.MaxValue));
+ this.AssertType(MessagePackType.Extension);
+ }
+
+ ///
+ /// Verifies that we can read values that use the Bin header, which is what MessagePack-CSharp's "native" formatter uses.
+ ///
+ ///
+ /// Note that while our mandates big endian encoding to match msgpack conventions,
+ /// The Bin encoding used by MessagePack-CSharp uses little-endian encoding.
+ ///
+ [Test]
+ public void UInt128_FromBin()
+ {
+ UInt128 value = new(1, 2);
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasUInt128.Value));
+ writer.WriteBinHeader(128 / 8);
+ Span byteSpan = writer.GetSpan(128 / 8);
+ Assert.True(((IBinaryInteger)value).TryWriteLittleEndian(byteSpan, out int written));
+ writer.Advance(written);
+ writer.Flush();
+
+ Assert.Equal(value, this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+#endif
+
+#if NET9_0_OR_GREATER
+
+ [Test]
+ public void OrderedDictionary() => this.AssertRoundtrip(new HasOrderedDictionary() { Map = { ['a'] = 1, ['b'] = 2, ['c'] = 3 } });
+
+#endif
+
+ [Test]
+ public void Decimal()
+ {
+ this.AssertRoundtrip(new HasDecimal(1.2m));
+ this.AssertRoundtrip(new HasDecimal(new decimal(ulong.MaxValue) * 1000));
+ this.AssertRoundtrip(new HasDecimal(new decimal(ulong.MaxValue) * -1000));
+
+ // Verify the actual encoding for one of these to lock it in.
+ MessagePackReader reader = new(this.lastRoundtrippedMsgpack);
+ Assert.Equal(1, reader.ReadMapHeader());
+ reader.Skip(default); // property name
+ Extension decimalEncoding = reader.ReadExtension();
+ Assert.Equal(this.Serializer.LibraryExtensionTypeCodes.Decimal, decimalEncoding.Header.TypeCode);
+ Assert.Equal("00-00-00-80-E7-03-00-00-18-FC-FF-FF-FF-FF-FF-FF", BitConverter.ToString(decimalEncoding.Data.ToArray()));
+ }
+
+ ///
+ /// Verifies that we can read values that use the Bin header, which is what MessagePack-CSharp's "native" formatter uses.
+ ///
+ [Test]
+ public void Decimal_FromBin()
+ {
+ Assert.SkipUnless(BitConverter.IsLittleEndian, "This test is written assuming little-endian.");
+ Span value = [new decimal(ulong.MaxValue) * -1000];
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasDecimal.Value));
+ writer.Write(MemoryMarshal.Cast(value));
+ writer.Flush();
+
+ Assert.Equal(value[0], this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+ ///
+ /// Verifies that we can read values that use the UTF-8 encoding, which is what MessagePack-CSharp's default formatter uses.
+ ///
+ [Test]
+ public void Decimal_FromString()
+ {
+ decimal value = 1.2m;
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasDecimal.Value));
+ writer.Write(value.ToString(CultureInfo.InvariantCulture));
+ writer.Flush();
+
+ Assert.Equal(value, this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+ [Test]
+ public void BigInteger()
+ {
+ this.AssertRoundtrip(new HasBigInteger(1));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasBigInteger(ulong.MaxValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasBigInteger(ulong.MinValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasBigInteger(long.MaxValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasBigInteger(long.MinValue));
+ this.AssertType(MessagePackType.Integer);
+
+ this.AssertRoundtrip(new HasBigInteger(new BigInteger(ulong.MaxValue) * 3));
+ this.AssertType(MessagePackType.Extension);
+ }
+
+ ///
+ /// Verifies that we can read values that use the Bin header, which is what MessagePack-CSharp's "native" formatter uses.
+ ///
+ [Test]
+ public void BigInteger_FromBin()
+ {
+ BigInteger value = new BigInteger(ulong.MaxValue) * 3;
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasBigInteger.Value));
+ writer.Write(value.ToByteArray()); // Always in LE order even on BE machines.
+ writer.Flush();
+
+ Assert.Equal(value, this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+ [Test]
+ public void CultureInfo_Roundtrips()
+ {
+ Assert.Equal("fr-FR", this.Roundtrip(CultureInfo.GetCultureInfo("fr-FR"))?.Name);
+ Assert.Equal("es", this.Roundtrip(CultureInfo.GetCultureInfo("es"))?.Name);
+ }
+
+ [Test]
+ public void CultureInfo_Encoding()
+ {
+ byte[] msgpack = this.Serializer.Serialize(CultureInfo.GetCultureInfo("es-ES"), this.TimeoutToken);
+ MessagePackReader reader = new(msgpack);
+ Assert.Equal("es-ES", reader.ReadString());
+ }
+
+ [Test]
+ public void EventArgs_Roundtrip()
+ {
+ Assert.NotNull(this.Roundtrip(new EventArgs()));
+ }
+
+ [Test]
+ public void Encoding_Roundtrip()
+ {
+ Assert.Equal(Encoding.UTF8.WebName, this.Roundtrip(Encoding.UTF8)?.WebName);
+ }
+
+ [Test]
+ public void Encoding_Encoding()
+ {
+ byte[] msgpack = this.Serializer.Serialize(Encoding.GetEncoding("utf-8"), this.TimeoutToken);
+ MessagePackReader reader = new(msgpack);
+ Assert.Equal("utf-8", reader.ReadString());
+ }
+
+ [Test, MatrixDataSource]
+ public void Guid_ParseAnyStringFormat(OptionalConverters.GuidStringFormat format, bool uppercase)
+ {
+ // Serialize the original with the specified format.
+ // Deserialize with any format besides the one we were expecting.
+ (Guid before, Guid after) = this.RoundtripModifiedGuid(
+ s => uppercase ? s.ToUpperInvariant() : s,
+ this.Serializer.WithGuidConverter(format),
+ this.Serializer.WithGuidConverter(format == OptionalConverters.GuidStringFormat.StringD ? OptionalConverters.GuidStringFormat.StringN : OptionalConverters.GuidStringFormat.StringD));
+
+ Assert.Equal(before, after);
+ }
+
+ [Test, MatrixDataSource]
+ public void Guid_TruncatedInputs(OptionalConverters.GuidStringFormat format)
+ {
+ this.Serializer = this.Serializer.WithGuidConverter(format);
+
+ bool empty = false;
+ int trimCount = 1;
+ while (!empty)
+ {
+ MessagePackSerializationException ex = Assert.Throws(() => this.RoundtripModifiedGuid(s =>
+ {
+ empty = s.Length == trimCount;
+ return s[..^trimCount++];
+ }));
+ Assert.Equal(BadGuidFormatErrorMessage, ex.GetBaseException().Message);
+ }
+ }
+
+ [Test, MatrixDataSource]
+ public void Guid_MissingHexCharacter(OptionalConverters.GuidStringFormat format)
+ {
+ this.Serializer = this.Serializer.WithGuidConverter(format);
+
+ // Remove a character that will be a hex character in any format.
+ MessagePackSerializationException ex = Assert.Throws(() => this.RoundtripModifiedGuid(s => s.Remove(6, 1)));
+ Console.WriteLine(ex.GetBaseException().Message);
+ Assert.Equal(BadGuidFormatErrorMessage, ex.GetBaseException().Message);
+ }
+
+ ///
+ /// Verifies that we can read values that use the Bin header, which is what MessagePack-CSharp's "native" formatter uses.
+ /// This tests interoperability with the default binary format.
+ ///
+ [Test]
+ public void Guid_FromBin()
+ {
+ Assert.SkipUnless(BitConverter.IsLittleEndian, "This test is written assuming little-endian.");
+
+ Span valueSpan = [System.Guid.NewGuid()];
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq);
+ writer.WriteMapHeader(1);
+ writer.Write(nameof(HasGuid.Value));
+
+ writer.Write(MemoryMarshal.Cast(valueSpan));
+ writer.Flush();
+
+ Assert.Equal(valueSpan[0], this.Serializer.Deserialize(seq, this.TimeoutToken)!.Value);
+ }
+
+ [Test]
+ public void DateTime() => this.AssertRoundtrip(new HasDateTime(System.DateTime.UtcNow));
+
+ [Test]
+ public void DateTime_Unspecified()
+ {
+ MessagePackSerializationException ex = Assert.Throws(() =>
+ this.Serializer.Serialize(new HasDateTime(new System.DateTime(2000, 1, 1)), this.TimeoutToken));
+ ArgumentException inner = Assert.IsType(ex.GetBaseException());
+ Console.WriteLine(inner.Message);
+ }
+
+ [Test]
+ [Arguments(DateTimeKind.Utc)]
+ [Arguments(DateTimeKind.Local)]
+ public void DateTime_Unspecified_UnderConfiguration(DateTimeKind kind)
+ {
+ this.Serializer = this.Serializer.WithAssumedDateTimeKind(kind);
+ DateTime original = new(2000, 1, 1); // Unspecified kind.
+ HasDateTime? deserialized = this.Roundtrip(new HasDateTime(original));
+
+ // Deserialized value should always be UTC.
+ Assert.Equal(System.DateTime.SpecifyKind(original, kind).ToUniversalTime(), deserialized?.Value);
+ Assert.Equal(DateTimeKind.Utc, deserialized?.Value.Kind);
+ }
+
+ [Test, MatrixDataSource]
+ public void DateTime_HiFi(DateTimeKind kind)
+ {
+ this.Serializer = this.Serializer.WithHiFiDateTime();
+ DateTime original = new(2000, 1, 1, 2, 3, 4, 567, kind);
+ HasDateTime? deserialized = this.Roundtrip(new HasDateTime(original));
+
+ // Deserialized value should have retained the Kind.
+ Assert.Equal(original.Kind, deserialized?.Value.Kind);
+
+ // And in all other ways, be equal.
+ Assert.Equal(original, deserialized?.Value);
+
+ // Verify the actual encoding for each case.
+ MessagePackReader reader = new(this.lastRoundtrippedMsgpack);
+ reader.ReadMapHeader();
+ reader.ReadString(); // skip property name
+ if (kind == DateTimeKind.Utc)
+ {
+ // Standard encoding.
+ Assert.Equal(original, reader.ReadDateTime());
+ }
+ else
+ {
+ // HiFi encoding.
+ Assert.Equal(2, reader.ReadArrayHeader());
+ Assert.Equal(original.Ticks, reader.ReadInt64());
+ Assert.Equal((int)original.Kind, reader.ReadInt32());
+ }
+ }
+
+ [Test]
+ public void DateTimeOffset()
+ {
+ this.AssertRoundtrip(new HasDateTimeOffset(System.DateTimeOffset.Now));
+
+ // Try specific offset values because CI/PR builds run on agents that run on the UTC time zone.
+ this.AssertRoundtrip(new HasDateTimeOffset(System.DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(4))));
+ }
+
+ [Test]
+ public void ByteArrayWithOldSpec()
+ {
+ byte[] original = [1, 2, 3];
+ Sequence seq = new();
+ MessagePackWriter writer = new(seq) { OldSpec = true };
+ this.Serializer.Serialize(ref writer, original, this.TimeoutToken);
+ writer.Flush();
+
+ // Verify that the test is doing what we think it is.
+ MessagePackReader reader = new(seq);
+ Assert.Equal(MessagePackType.String, reader.NextMessagePackType);
+
+ byte[]? deserialized = this.Serializer.Deserialize(seq, this.TimeoutToken);
+ Assert.Equal(original, deserialized);
+ }
+
+ [Test]
+ public void Extension() => this.AssertRoundtrip(new Extension(15, new byte[] { 1, 2, 3 }));
+
+ private (Guid Before, Guid After) RoundtripModifiedGuid(Func modifier, MessagePackSerializer? serializer = null, MessagePackSerializer? deserializer = null)
+ {
+ serializer ??= this.Serializer;
+ deserializer ??= this.Serializer;
+
+ Guid original = System.Guid.NewGuid();
+ Console.WriteLine($"Randomly generated guid: {original}");
+ byte[] msgpack = serializer.Serialize(original, this.TimeoutToken);
+ msgpack = this.Serializer.Serialize(
+ modifier(this.Serializer.Deserialize(msgpack, this.TimeoutToken)!),
+ this.TimeoutToken);
+ this.LogMsgPack(msgpack);
+ Guid deserialized = deserializer.Deserialize(msgpack, this.TimeoutToken);
+ return (original, deserialized);
+ }
+
+ private void AssertType(MessagePackType expectedType)
+ {
+ MessagePackReader reader = new(this.lastRoundtrippedMsgpack);
+ reader.ReadMapHeader();
+ reader.ReadString();
+ Assert.Equal(expectedType, reader.NextMessagePackType);
+ }
+
+ [GenerateShape]
+ public partial class HasImmutableDictionary : IEquatable
+ {
+ public ImmutableDictionary Map { get; set; } = ImmutableDictionary.Empty;
+
+ public bool Equals(HasImmutableDictionary? other) => StructuralEquality.Equal(this.Map, other?.Map);
+ }
+
+#if NET
+
+ [GenerateShape]
+ public partial record HasInt128(Int128 Value);
+
+ [GenerateShape]
+ public partial record HasUInt128(UInt128 Value);
+
+#endif
+
+#if NET9_0_OR_GREATER
+
+ [GenerateShape]
+ public partial class HasOrderedDictionary : IEquatable
+ {
+ public OrderedDictionary Map { get; set; } = new();
+
+ public bool Equals(HasOrderedDictionary? other) => StructuralEquality.Equal((IReadOnlyList>)this.Map, other?.Map);
+ }
+
+#endif
+
+ [GenerateShape]
+ public partial record HasDecimal(decimal Value);
+
+ [GenerateShape]
+ public partial record HasBigInteger(BigInteger Value);
+
+ [GenerateShape]
+ public partial record HasGuid(Guid Value);
+
+ [GenerateShape]
+ public partial record HasDateTime(DateTime Value);
+
+ [GenerateShape]
+ public partial record HasDateTimeOffset(DateTimeOffset Value);
+
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ [GenerateShapeFor]
+ private partial class Witness;
+}
diff --git a/test/Nerdbank.MessagePack.Tests/ConvertToJsonTests.cs b/test/Nerdbank.MessagePack.TUnit/ConvertToJsonTests.cs
similarity index 96%
rename from test/Nerdbank.MessagePack.Tests/ConvertToJsonTests.cs
rename to test/Nerdbank.MessagePack.TUnit/ConvertToJsonTests.cs
index ae5ee294..7008373f 100644
--- a/test/Nerdbank.MessagePack.Tests/ConvertToJsonTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/ConvertToJsonTests.cs
@@ -6,25 +6,25 @@
public partial class ConvertToJsonTests : MessagePackSerializerTestBase
{
- [Fact]
+ [Test]
public void Null() => this.AssertConvertToJson("null", null);
- [Fact]
+ [Test]
public void Simple() => this.AssertConvertToJson(@"{""Seeds"":3,""Is"":true,""Number"":1.2}", new Primitives(3, true, 1.2));
- [Fact]
+ [Test]
public void Simple2() => this.AssertConvertToJson(@"{""Seeds"":-3,""Is"":true,""Number"":-0.3}", new Primitives(-3, true, -0.3));
- [Fact]
+ [Test]
public void Array() => this.AssertConvertToJson(@"{""IntArray"":[1,2,3]}", new ArrayWrapper(1, 2, 3));
///
/// Verifies the behavior of the simpler method that takes a buffer and returns a string.
///
- [Fact]
+ [Test]
public void Sequence() => Assert.Equal("null", this.Serializer.ConvertToJson(new([0xc0])));
- [Fact]
+ [Test]
public void Guid_LittleEndian()
{
Guid guid = Guid.NewGuid();
@@ -35,7 +35,7 @@ public void Guid_LittleEndian()
new GuidWrapper(guid));
}
- [Fact]
+ [Test]
public void BigInteger()
{
BigInteger value = new BigInteger(ulong.MaxValue) * 3;
@@ -46,7 +46,7 @@ public void BigInteger()
new BigIntegerWrapper(value));
}
- [Fact]
+ [Test]
public void Decimal()
{
decimal value = new decimal(ulong.MaxValue) * 3;
@@ -58,7 +58,7 @@ public void Decimal()
}
#if NET
- [Fact]
+ [Test]
public void Int128()
{
foreach (Int128 value in new[] { System.Int128.MinValue, 0, System.Int128.MaxValue })
@@ -71,7 +71,7 @@ public void Int128()
}
}
- [Fact]
+ [Test]
public void UInt128()
{
foreach (UInt128 value in new[] { System.UInt128.MinValue, System.UInt128.MaxValue })
@@ -85,7 +85,7 @@ public void UInt128()
}
#endif
- [Fact]
+ [Test]
public void Indented_Object_Tabs()
{
this.AssertConvertToJson(
@@ -100,7 +100,7 @@ public void Indented_Object_Tabs()
new() { Indentation = "\t" });
}
- [Fact]
+ [Test]
public void Indented_Object_Spaces()
{
this.AssertConvertToJson(
@@ -115,7 +115,7 @@ public void Indented_Object_Spaces()
new() { Indentation = " " });
}
- [Fact]
+ [Test]
public void Indented_Array()
{
this.AssertConvertToJson(
@@ -132,7 +132,7 @@ public void Indented_Array()
new() { Indentation = "\t" });
}
- [Fact]
+ [Test]
public void Indented_TrailingCommas_Array()
{
this.AssertConvertToJson5(
@@ -152,7 +152,7 @@ public void Indented_TrailingCommas_Array()
///
/// Asserts that trailing commas are not added when we're not using newlines anyway.
///
- [Fact]
+ [Test]
public void TrailingCommas_IgnoredWithoutIndentation()
{
this.AssertConvertToJson(
@@ -163,7 +163,7 @@ public void TrailingCommas_IgnoredWithoutIndentation()
new() { TrailingCommas = true });
}
- [Fact]
+ [Test]
public void Indented_TrailingCommas()
{
this.AssertConvertToJson5(
@@ -178,7 +178,7 @@ public void Indented_TrailingCommas()
new() { Indentation = "\t", TrailingCommas = true });
}
- [Fact]
+ [Test]
public void Indented_NestingObject()
{
this.Serializer = this.Serializer with { SerializeDefaultValues = SerializeDefaultValuesPolicy.Required };
@@ -209,7 +209,7 @@ private void AssertConvertToJson([StringSyntax("json")] string expected, T? v
#endif
{
string json = this.ConvertToJson(value, options);
- this.Logger.WriteLine(json);
+ Console.WriteLine(json);
Assert.Equal(expected, json);
}
@@ -219,7 +219,7 @@ private void AssertConvertToJson5([StringSyntax("json5")] string expected, T?
#endif
{
string json = this.ConvertToJson(value, options);
- this.Logger.WriteLine(json);
+ Console.WriteLine(json);
Assert.Equal(expected, json);
}
diff --git a/test/Nerdbank.MessagePack.Tests/CustomConverterFactoryTests.cs b/test/Nerdbank.MessagePack.TUnit/CustomConverterFactoryTests.cs
similarity index 98%
rename from test/Nerdbank.MessagePack.Tests/CustomConverterFactoryTests.cs
rename to test/Nerdbank.MessagePack.TUnit/CustomConverterFactoryTests.cs
index 220eef1c..93289380 100644
--- a/test/Nerdbank.MessagePack.Tests/CustomConverterFactoryTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/CustomConverterFactoryTests.cs
@@ -11,7 +11,7 @@ internal partial interface IMarshaledInterface
Task DoSomethingAsync();
}
- [Fact]
+ [Test]
public void CustomUnionSerializer()
{
this.Serializer = this.Serializer with { ConverterFactories = [new CustomUnionConverterFactory()] };
@@ -29,7 +29,7 @@ public void CustomUnionSerializer()
Assert.True(bAsB.CustomSerialized);
}
- [Fact]
+ [Test]
public void MarshaledInterfaceSerializer()
{
this.Serializer = this.Serializer with { ConverterFactories = [new MarshaledObjectConverterFactory()] };
@@ -39,8 +39,8 @@ public void MarshaledInterfaceSerializer()
Assert.IsType(proxy);
}
- [Fact]
- [Trait("ReferencePreservation", "true")]
+ [Test]
+ [Property("ReferencePreservation", "true")]
public void FactoryWithReferencePreservation()
{
this.Serializer = this.Serializer with
@@ -59,7 +59,7 @@ public void FactoryWithReferencePreservation()
Assert.True(deserialized[0].CustomSerialized);
}
- [Fact]
+ [Test]
public void GetSubConverterFromContext()
{
this.Serializer = this.Serializer with { ConverterFactories = [new DoubleArrayWrapperFactory()] };
diff --git a/test/Nerdbank.MessagePack.Tests/CustomConverterTests.cs b/test/Nerdbank.MessagePack.TUnit/CustomConverterTests.cs
similarity index 98%
rename from test/Nerdbank.MessagePack.Tests/CustomConverterTests.cs
rename to test/Nerdbank.MessagePack.TUnit/CustomConverterTests.cs
index 7e2bb860..5dd8aeda 100644
--- a/test/Nerdbank.MessagePack.Tests/CustomConverterTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/CustomConverterTests.cs
@@ -6,20 +6,20 @@
public partial class CustomConverterTests : MessagePackSerializerTestBase
{
- [Fact]
+ [Test]
public void ConverterThatDelegates()
{
this.AssertRoundtrip(new CustomType { InternalProperty = "Hello, World!" });
}
- [Fact]
+ [Test]
public void AttributedTypeWorksAfterFirstSerialization()
{
this.AssertRoundtrip(new Tree(3));
this.AssertRoundtrip(new CustomType { InternalProperty = "Hello, World!" });
}
- [Fact]
+ [Test]
public void RegisterWorksAfterFirstSerialization()
{
this.AssertRoundtrip(new Tree(3));
@@ -33,21 +33,21 @@ public void RegisterWorksAfterFirstSerialization()
Assert.Equal(2, treeConverter.InvocationCount);
}
- [Fact]
+ [Test]
public void UseNonGenericSubConverters_ShapeProvider()
{
this.Serializer = this.Serializer with { Converters = [new CustomTypeConverterNonGenericTypeShapeProvider()] };
this.AssertRoundtrip(new CustomType { InternalProperty = "Hello, World!" });
}
- [Fact]
+ [Test]
public void UseNonGenericSubConverters_Shape()
{
this.Serializer = this.Serializer with { Converters = [new CustomTypeConverterNonGenericTypeShape()] };
this.AssertRoundtrip(new CustomType { InternalProperty = "Hello, World!" });
}
- [Fact]
+ [Test]
public void StatefulConverters()
{
SerializationContext modifiedStarterContext = this.Serializer.StartingContext;
@@ -66,14 +66,14 @@ public void StatefulConverters()
Assert.Null(this.Serializer.StartingContext["SHOULDVANISH"]);
}
- [Fact]
+ [Test]
public void GenericDataAndGenericConverterByOpenGenericAttribute()
{
GenericData? deserialized = this.Roundtrip, Witness>(new GenericData { Value = "Hello, World!" });
Assert.Equal("Hello, World!11", deserialized?.Value);
}
- [Fact]
+ [Test]
public void GenericDataAndGenericConverterByClosedGenericRuntimeRegistration()
{
this.Serializer = this.Serializer with { Converters = [new GenericDataConverter2()] };
@@ -81,7 +81,7 @@ public void GenericDataAndGenericConverterByClosedGenericRuntimeRegistration()
Assert.Equal("Hello, World!22", deserialized?.Value);
}
- [Fact]
+ [Test]
public void GenericDataAndGenericConverterByOpenGenericRuntimeRegistration()
{
this.Serializer = this.Serializer with { ConverterTypes = [typeof(GenericDataConverter2<>)] };
@@ -89,7 +89,7 @@ public void GenericDataAndGenericConverterByOpenGenericRuntimeRegistration()
Assert.Equal("Hello, World!22", deserialized?.Value);
}
- [Fact]
+ [Test]
public void GenericDataAndNonGenericConverterByRuntimeRegistration()
{
this.Serializer = this.Serializer with { ConverterTypes = [typeof(GenericDataConverterNonGeneric)] };
@@ -101,7 +101,7 @@ public void GenericDataAndNonGenericConverterByRuntimeRegistration()
Assert.Equal("Hello, World!11", deserialized2?.Value);
}
- [Fact]
+ [Test]
public void NonGenericRuntimeRegistrationOfConverterByType()
{
this.Serializer = this.Serializer with { ConverterTypes = [typeof(TreeConverterPlus2)] };
@@ -109,15 +109,15 @@ public void NonGenericRuntimeRegistrationOfConverterByType()
Assert.Equal(5, deserialized?.FruitCount);
}
- [Fact]
+ [Test]
public void GenericDataAndGenericConverterByOpenGenericRuntimeRegistration_NotAssociated()
{
this.Serializer = this.Serializer with { ConverterTypes = [typeof(GenericDataConverter3<>)] };
- MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Serialize, Witness>(new GenericData { Value = "Hello, World!" }, TestContext.Current.CancellationToken));
- this.Logger.WriteLine(ex.Message);
+ MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Serialize, Witness>(new GenericData { Value = "Hello, World!" }, this.TimeoutToken));
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void ConverterWithConverterContextConstructor()
{
this.Serializer = this.Serializer with { ConverterTypes = [typeof(TreeConverterWithConverterContext)] };
diff --git a/test/Nerdbank.MessagePack.Tests/CustomEnumerableTypes.cs b/test/Nerdbank.MessagePack.TUnit/CustomEnumerableTypes.cs
similarity index 99%
rename from test/Nerdbank.MessagePack.Tests/CustomEnumerableTypes.cs
rename to test/Nerdbank.MessagePack.TUnit/CustomEnumerableTypes.cs
index 00dfb94d..a2a3b801 100644
--- a/test/Nerdbank.MessagePack.Tests/CustomEnumerableTypes.cs
+++ b/test/Nerdbank.MessagePack.TUnit/CustomEnumerableTypes.cs
@@ -3,7 +3,7 @@
public partial class CustomEnumerableTypes : MessagePackSerializerTestBase
{
- [Fact]
+ [Test]
public void CustomListOfIntDerivedCollection()
{
ListOfInt list = new() { 1, 2, 3 };
diff --git a/test/Nerdbank.MessagePack.Tests/DerivedTypeDuckTypingTests.cs b/test/Nerdbank.MessagePack.TUnit/DerivedTypeDuckTypingTests.cs
similarity index 88%
rename from test/Nerdbank.MessagePack.Tests/DerivedTypeDuckTypingTests.cs
rename to test/Nerdbank.MessagePack.TUnit/DerivedTypeDuckTypingTests.cs
index 25019430..79053a01 100644
--- a/test/Nerdbank.MessagePack.Tests/DerivedTypeDuckTypingTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/DerivedTypeDuckTypingTests.cs
@@ -9,16 +9,24 @@ public DerivedTypeDuckTypingTests()
{
this.Serializer = this.Serializer with
{
+#if NET
+ DerivedTypeUnions = [
+ new DerivedTypeDuckTyping(
+ TypeShapeResolver.Resolve(),
+ TypeShapeResolver.Resolve(),
+ TypeShapeResolver.Resolve()),
+#else
DerivedTypeUnions = [
new DerivedTypeDuckTyping(
TypeShapeResolver.ResolveDynamicOrThrow(),
TypeShapeResolver.ResolveDynamicOrThrow(),
TypeShapeResolver.ResolveDynamicOrThrow()),
+#endif
],
};
}
- [Fact]
+ [Test]
public void RequiredPropertyDistinction_Roundtrip()
{
this.AssertRoundtrip(new Dog("Buddy", 5));
diff --git a/test/Nerdbank.MessagePack.Tests/DerivedTypeMappingTests.cs b/test/Nerdbank.MessagePack.TUnit/DerivedTypeMappingTests.cs
similarity index 94%
rename from test/Nerdbank.MessagePack.Tests/DerivedTypeMappingTests.cs
rename to test/Nerdbank.MessagePack.TUnit/DerivedTypeMappingTests.cs
index b35642b4..d1d45641 100644
--- a/test/Nerdbank.MessagePack.Tests/DerivedTypeMappingTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/DerivedTypeMappingTests.cs
@@ -1,9 +1,9 @@
// Copyright (c) Andrew Arnott. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-public partial class DerivedTypeMappingTests(ITestOutputHelper logger)
+public partial class DerivedTypeMappingTests : MessagePackSerializerTestBase
{
- [Fact]
+ [Test]
public void NonUniqueAliasesRejected_Integers()
{
DerivedShapeMapping mapping = new();
@@ -14,10 +14,10 @@ public void NonUniqueAliasesRejected_Integers()
mapping.Add(1, Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add(1, Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void NonUniqueAliasesRejected_Strings()
{
DerivedShapeMapping mapping = new();
@@ -28,10 +28,10 @@ public void NonUniqueAliasesRejected_Strings()
mapping.Add("A", Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add("A", Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void NonUniqueTypesRejected_Integers()
{
DerivedShapeMapping mapping = new();
@@ -42,10 +42,10 @@ public void NonUniqueTypesRejected_Integers()
mapping.Add(1, Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add(2, Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void NonUniqueTypesRejected_Strings()
{
DerivedShapeMapping mapping = new();
@@ -56,10 +56,10 @@ public void NonUniqueTypesRejected_Strings()
mapping.Add("A", Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add(2, Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void NonUniquePairsRejected_Integers()
{
DerivedShapeMapping mapping = new();
@@ -70,10 +70,10 @@ public void NonUniquePairsRejected_Integers()
mapping.Add(1, Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add(1, Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void NonUniquePairsRejected_Strings()
{
DerivedShapeMapping mapping = new();
@@ -84,10 +84,10 @@ public void NonUniquePairsRejected_Strings()
mapping.Add("A", Witness.GeneratedTypeShapeProvider);
ArgumentException ex = Assert.Throws(() => mapping.Add("A", Witness.GeneratedTypeShapeProvider));
#endif
- logger.WriteLine(ex.Message);
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void ObjectInitializerSyntax()
{
DerivedTypeMapping mapping = new(Witness.GeneratedTypeShapeProvider)
@@ -100,7 +100,7 @@ public void ObjectInitializerSyntax()
Assert.Equal(typeof(MyDerivedB), mapping["B"]);
}
- [Fact]
+ [Test]
public void DictionaryInitializerSyntax()
{
DerivedTypeMapping mapping = new(Witness.GeneratedTypeShapeProvider)
@@ -113,7 +113,7 @@ public void DictionaryInitializerSyntax()
Assert.Equal(typeof(MyDerivedB), mapping["B"]);
}
- [Fact]
+ [Test]
public void ObjectInitializerSyntax_NonUniqueTypes()
{
Assert.Throws(() =>
@@ -126,7 +126,7 @@ public void ObjectInitializerSyntax_NonUniqueTypes()
});
}
- [Fact]
+ [Test]
public void ObjectInitializerSyntax_NonUniqueAlias()
{
Assert.Throws(() =>
@@ -139,7 +139,7 @@ public void ObjectInitializerSyntax_NonUniqueAlias()
});
}
- [Fact]
+ [Test]
public void DictionaryInitializerSyntax_NonUniqueTypes()
{
Assert.Throws(() =>
@@ -152,7 +152,7 @@ public void DictionaryInitializerSyntax_NonUniqueTypes()
});
}
- [Fact]
+ [Test]
public void DictionaryInitializerSyntax_AddTypeAgainAfterImplicitRemoval()
{
DerivedTypeMapping mapping = new(Witness.GeneratedTypeShapeProvider)
@@ -166,7 +166,7 @@ public void DictionaryInitializerSyntax_AddTypeAgainAfterImplicitRemoval()
Assert.Equal(typeof(MyDerivedA), mapping["A"]);
}
- [Fact]
+ [Test]
public void DerivedShapeMapping_DisabledTests()
{
var union = DerivedTypeUnion.CreateDisabled(typeof(MyBase));
@@ -174,7 +174,7 @@ public void DerivedShapeMapping_DisabledTests()
Assert.Same(typeof(MyBase), union.BaseType);
}
- [Fact]
+ [Test]
[SuppressMessage("Assertions", "xUnit2013:Do not use equality check to check for collection size.", Justification = "The whole point of this test is to ensure that the Count property matches what the enumerator would produce.")]
public void EnumerateMappings()
{
@@ -187,7 +187,7 @@ public void EnumerateMappings()
Assert.Equal(serializer.DerivedTypeUnions.Count, serializer.DerivedTypeUnions.Count());
}
- [Fact]
+ [Test]
public void ShapeMappingFrozenAfterAdding()
{
DerivedShapeMapping mapping = new();
@@ -209,7 +209,7 @@ public void ShapeMappingFrozenAfterAdding()
#endif
}
- [Fact]
+ [Test]
public void TypeMappingFrozenAfterAdding()
{
DerivedTypeMapping mapping = new(Witness.GeneratedTypeShapeProvider)
diff --git a/test/Nerdbank.MessagePack.Tests/DerivedTypeTests.cs b/test/Nerdbank.MessagePack.TUnit/DerivedTypeTests.cs
similarity index 96%
rename from test/Nerdbank.MessagePack.Tests/DerivedTypeTests.cs
rename to test/Nerdbank.MessagePack.TUnit/DerivedTypeTests.cs
index 14af0e31..67e17cb2 100644
--- a/test/Nerdbank.MessagePack.Tests/DerivedTypeTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/DerivedTypeTests.cs
@@ -3,7 +3,7 @@
public partial class DerivedTypeTests : MessagePackSerializerTestBase
{
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task BaseType(bool async)
{
BaseClass value = new() { BaseClassProperty = 5 };
@@ -17,7 +17,7 @@ public async Task BaseType(bool async)
Assert.Equal(nameof(BaseClass.BaseClassProperty), reader.ReadString());
}
- [Fact]
+ [Test]
public void BaseTypeExplicitIdentifier()
{
BaseTypeExplicitBase? result = this.Roundtrip(new BaseTypeExplicitBase());
@@ -34,7 +34,7 @@ public void BaseTypeExplicitIdentifier()
Assert.Equal(0, reader.ReadMapHeader());
}
- [Fact]
+ [Test]
public void BaseTypeExplicitIdentifier_RuntimeMapping()
{
this.Serializer = this.Serializer with { SerializeDefaultValues = SerializeDefaultValuesPolicy.Required };
@@ -52,7 +52,7 @@ public void BaseTypeExplicitIdentifier_RuntimeMapping()
Assert.Equal(0, reader.ReadMapHeader());
}
- [Fact]
+ [Test]
public void DerivedAType()
{
ReadOnlySequence msgpack = this.AssertRoundtrip(new DerivedA { BaseClassProperty = 5, DerivedAProperty = 6 });
@@ -67,7 +67,7 @@ public void DerivedAType()
Assert.True(reader.End);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task DerivedA_AsBaseType(bool async)
{
var value = new DerivedA { BaseClassProperty = 5, DerivedAProperty = 6 };
@@ -81,26 +81,26 @@ public async Task DerivedA_AsBaseType(bool async)
}
}
- [Fact]
+ [Test]
public void DerivedAA_AsBaseType() => this.AssertRoundtrip(new DerivedAA { BaseClassProperty = 5, DerivedAProperty = 6 });
- [Fact]
+ [Test]
public void DerivedB_AsBaseType() => this.AssertRoundtrip(new DerivedB(10) { BaseClassProperty = 5 });
- [Fact]
+ [Test]
public void EnumerableDerived_BaseType()
{
// This is a lossy operation. Only the collection elements are serialized,
// and the class cannot be deserialized because the constructor doesn't take a collection.
EnumerableDerived value = new(3) { BaseClassProperty = 5 };
- byte[] msgpack = this.Serializer.Serialize(value, TestContext.Current.CancellationToken);
- this.Logger.WriteLine(this.Serializer.ConvertToJson(msgpack));
+ byte[] msgpack = this.Serializer.Serialize(value, this.TimeoutToken);
+ Console.WriteLine(this.Serializer.ConvertToJson(msgpack));
}
- [Fact]
+ [Test]
public void ClosedGenericDerived_BaseType() => this.AssertRoundtrip(new DerivedGeneric(5) { BaseClassProperty = 10 });
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task Null(bool async)
{
if (async)
@@ -113,7 +113,7 @@ public async Task Null(bool async)
}
}
- [Fact]
+ [Test]
public void UnrecognizedAlias()
{
Sequence sequence = new();
@@ -123,11 +123,11 @@ public void UnrecognizedAlias()
writer.WriteMapHeader(0);
writer.Flush();
- MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Deserialize(sequence, TestContext.Current.CancellationToken));
- this.Logger.WriteLine(ex.Message);
+ MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Deserialize(sequence, this.TimeoutToken));
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void UnrecognizedArraySize()
{
Sequence sequence = new();
@@ -138,18 +138,18 @@ public void UnrecognizedArraySize()
writer.WriteNil();
writer.Flush();
- MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Deserialize(sequence, TestContext.Current.CancellationToken));
- this.Logger.WriteLine(ex.Message);
+ MessagePackSerializationException ex = Assert.Throws(() => this.Serializer.Deserialize(sequence, this.TimeoutToken));
+ Console.WriteLine(ex.Message);
}
- [Fact]
+ [Test]
public void UnknownDerivedType()
{
BaseClass? result = this.Roundtrip(new UnknownDerived());
Assert.IsType(result);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public void UnknownDerivedType_PrefersClosestMatch(bool runtimeMapping)
{
if (runtimeMapping)
@@ -165,7 +165,7 @@ public void UnknownDerivedType_PrefersClosestMatch(bool runtimeMapping)
Assert.IsType(this.Roundtrip(new DerivedAAUnknown()));
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task MixedAliasTypes(bool async)
{
MixedAliasBase value = new MixedAliasDerivedA();
@@ -181,7 +181,7 @@ public async Task MixedAliasTypes(bool async)
Assert.Equal(10, reader.ReadInt32());
}
- [Fact]
+ [Test]
public void ImpliedAlias()
{
ReadOnlySequence msgpack = this.AssertRoundtrip(new ImpliedAliasDerived());
@@ -190,7 +190,7 @@ public void ImpliedAlias()
Assert.Equal(typeof(ImpliedAliasDerived).Name, reader.ReadString());
}
- [Fact]
+ [Test]
public void RecursiveSubTypes()
{
// If it were to work, this is how we expect it to work:
@@ -202,7 +202,7 @@ public void RecursiveSubTypes()
Assert.Equal(13, reader.ReadInt32());
}
- [Fact]
+ [Test]
public void RuntimeRegistration_Integers()
{
DerivedShapeMapping mapping = new();
@@ -220,7 +220,7 @@ public void RuntimeRegistration_Integers()
this.AssertRoundtrip(new DynamicallyRegisteredDerivedB());
}
- [Fact]
+ [Test]
public void RuntimeRegistration_Strings()
{
DerivedShapeMapping mapping = new();
@@ -238,7 +238,7 @@ public void RuntimeRegistration_Strings()
this.AssertRoundtrip(new DynamicallyRegisteredDerivedB());
}
- [Fact]
+ [Test]
public void RuntimeRegistration_OverridesStatic()
{
DerivedShapeMapping mapping = new();
@@ -265,7 +265,7 @@ public void RuntimeRegistration_OverridesStatic()
///
/// Verify that an empty mapping is allowed and produces the schema that allows for sub-types to be added in the future.
///
- [Fact]
+ [Test]
public void RuntimeRegistration_EmptyMapping()
{
DerivedShapeMapping mapping = new();
@@ -277,7 +277,7 @@ public void RuntimeRegistration_EmptyMapping()
Assert.Equal(0, reader.ReadMapHeader());
}
- [Fact]
+ [Test]
public void CustomConverter_InvokedAsUnionCase_WhenSetAsRuntimeConverter()
{
this.Serializer = this.Serializer with { Converters = [new BaseClassCustomConverter()] };
@@ -289,7 +289,7 @@ public void CustomConverter_InvokedAsUnionCase_WhenSetAsRuntimeConverter()
this.AssertRoundtrip(new BaseTypeWithCustomConverterAttributeDerived { BaseClassProperty = 8, DerivedAProperty = 10 });
}
- [Fact]
+ [Test]
public void CustomConverter_InvokedAsUnionCase_WhenSetViaConverterAttribute()
{
this.AssertRoundtrip(new() { BaseClassProperty = 5 });
@@ -299,7 +299,7 @@ public void CustomConverter_InvokedAsUnionCase_WhenSetViaConverterAttribute()
this.AssertRoundtrip(new BaseTypeWithCustomConverterAttributeDerived { BaseClassProperty = 8, DerivedAProperty = 10 });
}
- [Fact]
+ [Test]
public void CustomConverter_InvokedAsUnionCase_WhenSetViaConverterAttributeOnMember()
{
this.AssertRoundtrip(new() { Value = new BaseClass { BaseClassProperty = 5 } });
@@ -312,7 +312,7 @@ public void CustomConverter_InvokedAsUnionCase_WhenSetViaConverterAttributeOnMem
Assert.Equal(new HasUnionMemberWithMemberAttribute { Value = new BaseClass { BaseClassProperty = 8 } }, deserialized);
}
- [Fact]
+ [Test]
public void DisableAttributeUnionAtRuntime()
{
this.Serializer = this.Serializer with
diff --git a/test/Nerdbank.MessagePack.Tests/DeserializeDefaultValueTests.cs b/test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs
similarity index 91%
rename from test/Nerdbank.MessagePack.Tests/DeserializeDefaultValueTests.cs
rename to test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs
index dc2c532d..316d5ebb 100644
--- a/test/Nerdbank.MessagePack.Tests/DeserializeDefaultValueTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/DeserializeDefaultValueTests.cs
@@ -7,19 +7,19 @@ public partial class DeserializeDefaultValueTests : MessagePackSerializerTestBas
private static readonly ReadOnlySequence EmptyMsgPackMap = CreateEmptyMap();
private static readonly ReadOnlySequence EmptyMsgPackArray = CreateEmptyArray();
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task NullValueRejectedForNonNullableRequiredProperty(bool async)
{
await this.ExpectDeserializationThrowsAsync(NullMessageMsgPackMap, async, MessagePackSerializationException.ErrorCode.DisallowedNullValue);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task NullValueRejectedForNonNullableOptionalProperty(bool async)
{
await this.ExpectDeserializationThrowsAsync(NullMessageMsgPackMap, async, MessagePackSerializationException.ErrorCode.DisallowedNullValue);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task NullValueAllowedForNonNullableOptionalProperty_WithFlag(bool async)
{
this.Serializer = this.Serializer with { DeserializeDefaultValues = DeserializeDefaultValuesPolicy.AllowNullValuesForNonNullableProperties };
@@ -28,7 +28,7 @@ public async Task NullValueAllowedForNonNullableOptionalProperty_WithFlag(bool a
Assert.Null(deserialized.Message);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task NullValueAllowedForNonNullableRequiredProperty_WithFlag(bool async)
{
this.Serializer = this.Serializer with { DeserializeDefaultValues = DeserializeDefaultValuesPolicy.AllowNullValuesForNonNullableProperties };
@@ -37,25 +37,25 @@ public async Task NullValueAllowedForNonNullableRequiredProperty_WithFlag(bool a
Assert.Null(deserialized.Message);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task RejectMissingValueForNonNullableRequiredProperty(bool async)
{
await this.ExpectDeserializationThrowsAsync(EmptyMsgPackMap, async, MessagePackSerializationException.ErrorCode.MissingRequiredProperty);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task RejectMissingValueForNonNullableRequiredProperty_KeyedMap(bool async)
{
await this.ExpectDeserializationThrowsAsync(EmptyMsgPackMap, async, MessagePackSerializationException.ErrorCode.MissingRequiredProperty);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task RejectMissingValueForNonNullableRequiredProperty_KeyedArray(bool async)
{
await this.ExpectDeserializationThrowsAsync(EmptyMsgPackArray, async, MessagePackSerializationException.ErrorCode.MissingRequiredProperty);
}
- [Fact]
+ [Test]
public async Task RejectMissingValueForRequiredPropertyFromVeryLargeType()
{
Sequence seq = new();
@@ -73,7 +73,7 @@ public async Task RejectMissingValueForRequiredPropertyFromVeryLargeType()
Assert.Contains("P64, P65, P66", ex.Message);
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task MissingValueAllowedForNonNullableOptionalProperty(bool async)
{
OptionalNonNullProperty? deserialized = await this.DeserializeMaybeAsync(EmptyMsgPackMap, async);
@@ -81,7 +81,7 @@ public async Task MissingValueAllowedForNonNullableOptionalProperty(bool async)
Assert.Equal(string.Empty, deserialized.Message); // When omitted, the default value is the empty string for this particular property.
}
- [Theory, PairwiseData]
+ [Test, MatrixDataSource]
public async Task MissingValueAllowedForNonNullableRequiredProperty_WithFlag(bool async)
{
this.Serializer = this.Serializer with { DeserializeDefaultValues = DeserializeDefaultValuesPolicy.AllowMissingValuesForRequiredProperties };
@@ -125,8 +125,8 @@ private static ReadOnlySequence CreateEmptyArray()
#endif
{
return async
- ? await this.Serializer.DeserializeAsync(new MemoryStream(msgpack.ToArray()), TestContext.Current.CancellationToken)
- : this.Serializer.Deserialize(msgpack, TestContext.Current.CancellationToken);
+ ? await this.Serializer.DeserializeAsync(new MemoryStream(msgpack.ToArray()), this.TimeoutToken)
+ : this.Serializer.Deserialize(msgpack, this.TimeoutToken);
}
private async ValueTask ExpectDeserializationThrowsAsync(ReadOnlySequence msgpack, bool async, MessagePackSerializationException.ErrorCode expectedCause)
@@ -135,9 +135,9 @@ private async ValueTask ExpectDeserialization
#endif
{
MessagePackSerializationException ex = async
- ? await Assert.ThrowsAsync(() => this.Serializer.DeserializeAsync(new MemoryStream(msgpack.ToArray()), TestContext.Current.CancellationToken).AsTask())
- : Assert.Throws(() => this.Serializer.Deserialize(msgpack, TestContext.Current.CancellationToken));
- this.Logger.WriteLine(ex.GetBaseException().Message);
+ ? await Assert.ThrowsAsync(() => this.Serializer.DeserializeAsync(new MemoryStream(msgpack.ToArray()), this.TimeoutToken).AsTask())
+ : Assert.Throws(() => this.Serializer.Deserialize(msgpack, this.TimeoutToken));
+ Console.WriteLine(ex.GetBaseException().Message);
MessagePackSerializationException rootCauseException = Assert.IsType(ex.GetBaseException());
Assert.Equal(expectedCause, rootCauseException.Code);
diff --git a/test/Nerdbank.MessagePack.Tests/DeserializePathTests.cs b/test/Nerdbank.MessagePack.TUnit/DeserializePathTests.cs
similarity index 78%
rename from test/Nerdbank.MessagePack.Tests/DeserializePathTests.cs
rename to test/Nerdbank.MessagePack.TUnit/DeserializePathTests.cs
index 041581a0..086ae09b 100644
--- a/test/Nerdbank.MessagePack.Tests/DeserializePathTests.cs
+++ b/test/Nerdbank.MessagePack.TUnit/DeserializePathTests.cs
@@ -11,110 +11,110 @@ public enum TestEnum
}
// Test deserializing the root object.
- [Fact]
+ [Test]
public void RootObject()
{
OuterContainer container = new(new(5));
- byte[] msgpack = this.Serializer.Serialize(container, TestContext.Current.CancellationToken);
+ byte[] msgpack = this.Serializer.Serialize(container, this.TimeoutToken);
this.LogMsgPack(msgpack);
MessagePackSerializer.DeserializePathOptions options = new(c => c);
- OuterContainer? result = this.Serializer.DeserializePath(msgpack, options, TestContext.Current.CancellationToken);
+ OuterContainer? result = this.Serializer.DeserializePath(msgpack, options, this.TimeoutToken);
Assert.NotNull(result);
Assert.Equal(5, result.Inner?.Value);
}
- [Fact]
+ [Test]
public void OneStepObject()
{
OuterContainer container = new(new(5));
- byte[] msgpack = this.Serializer.Serialize(container, TestContext.Current.CancellationToken);
+ byte[] msgpack = this.Serializer.Serialize(container, this.TimeoutToken);
this.LogMsgPack(msgpack);
MessagePackSerializer.DeserializePathOptions options = new(c => c.Inner!);
- InnerValue? result = this.Serializer.DeserializePath(msgpack, options, TestContext.Current.CancellationToken);
+ InnerValue? result = this.Serializer.DeserializePath(msgpack, options, this.TimeoutToken);
Assert.NotNull(result);
Assert.Equal(5, result.Value);
}
// Test deserializing a primitive at the end of a non-empty path.
- [Fact]
+ [Test]
public void NestedPrimitive()
{
OuterContainer container = new(new(42));
- byte[] msgpack = this.Serializer.Serialize(container, TestContext.Current.CancellationToken);
+ byte[] msgpack = this.Serializer.Serialize(container, this.TimeoutToken);
this.LogMsgPack(msgpack);
MessagePackSerializer.DeserializePathOptions options = new(c => c.Inner!.Value);
- int result = this.Serializer.DeserializePath(msgpack, options, TestContext.Current.CancellationToken);
+ int result = this.Serializer.DeserializePath(msgpack, options, this.TimeoutToken);
Assert.Equal(42, result);
}
// Test deserializing an object at the end of a non-empty path.
- [Fact]
+ [Test]
public void NestedObject()
{
ThreeLevelContainer container = new(new(new(99)));
- byte[] msgpack = this.Serializer.Serialize(container, TestContext.Current.CancellationToken);
+ byte[] msgpack = this.Serializer.Serialize