protected void RunTest(BinaryTestData <T> test, ValueConverter <T> converter = null) { switch (test.Type) { case TestType.FailRead: Assert.Throws <SerializationException>(() => _serializer.Read(test.Bytes, converter)); break; case TestType.FailWrite: Assert.Throws <SerializationException>(() => _serializer.Write(test.Value, converter)); break; case TestType.Read: Assert.Equal(test.Value, _serializer.Read(test.Bytes, converter), _comparer); Assert.True(TestSkip(test.Bytes)); break; case TestType.Write: Assert.True(test.Bytes.Span.SequenceEqual(_serializer.Write(test.Value, converter).AsReadOnlySpan())); break; case TestType.ReadWrite: Assert.Equal(test.Value, _serializer.Read(test.Bytes, converter), _comparer); Assert.True(TestSkip(test.Bytes)); Assert.True(test.Bytes.Span.SequenceEqual(_serializer.Write(test.Value, converter).AsReadOnlySpan())); break; } }
public void Format_O(BinaryTestData <DateTimeOffset> data) => RunTest(data, new DateTimeOffsetEtfConverter('O'));
public void Atom(BinaryTestData <bool> data) => RunTest(data);
public void String(BinaryTestData <string> data) => RunTest(data);
public void Nullable(BinaryTestData <int?> data) => RunTest(data);
public void Number(BinaryTestData <double> data) => RunTest(data);
public void Number(BinaryTestData <float> data) => RunTest(data);
public void Format_G(BinaryTestData <decimal> data) => RunTest(data);
public void Number(BinaryTestData <sbyte> data) => RunTest(data);
public void Format_N(BinaryTestData <long> data) => RunTest(data, new Int64EtfConverter('N'));
public void Format_X(BinaryTestData <int> data) => RunTest(data, new Int32EtfConverter('X'));
public void Format_N(BinaryTestData <short> data) => RunTest(data, new Int16EtfConverter('N'));
public void Array(BinaryTestData <int[]> data) => RunTest(data);
public void Array(BinaryTestData <List <int> > data) => RunTest(data);
public void Format_LittleG(BinaryTestData <TimeSpan> data) => RunTest(data, new TimeSpanEtfConverter('g'));
public void Format_N(BinaryTestData <sbyte> data) => RunTest(data, new SByteEtfConverter('N'));
public void Dictionary(BinaryTestData <Dictionary <string, int> > data) => RunTest(data);
public void Format_N(BinaryTestData <uint> data) => RunTest(data, new UInt32EtfConverter('N'));
public void Format_LittleE(BinaryTestData <decimal> data) => RunTest(data, new DecimalEtfConverter('e'));
public void Number(BinaryTestData <ulong> data) => RunTest(data);
public void Format_LittleE(BinaryTestData <float> data) => RunTest(data, new SingleEtfConverter('e'));
public void Format_X(BinaryTestData <ulong> data) => RunTest(data, new UInt64EtfConverter('X'));
public void Format_LittleE(BinaryTestData <double> data) => RunTest(data, new DoubleEtfConverter('e'));
public void Format_X(BinaryTestData <byte> data) => RunTest(data, new ByteEtfConverter('X'));
public void Format_N(BinaryTestData <Guid> data) => RunTest(data, new GuidEtfConverter('N'));
public void Number(BinaryTestData <ushort> data) => RunTest(data);
public void SmallAtomUtf8(BinaryTestData <bool> data) => RunTest(data);
public void Format_X(BinaryTestData <ushort> data) => RunTest(data, new UInt16EtfConverter('X'));
public void Format_LittleL(BinaryTestData <bool> data) => RunTest(data, new BooleanEtfConverter('l'));
public void Format_Default(BinaryTestData <DateTimeOffset> data) => RunTest(data);