예제 #1
0
        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;
            }
        }
예제 #2
0
 public void Format_O(BinaryTestData <DateTimeOffset> data) => RunTest(data, new DateTimeOffsetEtfConverter('O'));
예제 #3
0
 public void Atom(BinaryTestData <bool> data) => RunTest(data);
예제 #4
0
 public void String(BinaryTestData <string> data) => RunTest(data);
예제 #5
0
 public void Nullable(BinaryTestData <int?> data) => RunTest(data);
예제 #6
0
 public void Number(BinaryTestData <double> data) => RunTest(data);
예제 #7
0
 public void Number(BinaryTestData <float> data) => RunTest(data);
예제 #8
0
 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'));
예제 #13
0
 public void Array(BinaryTestData <int[]> data) => RunTest(data);
예제 #14
0
 public void Array(BinaryTestData <List <int> > data) => RunTest(data);
예제 #15
0
 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'));
예제 #19
0
 public void Format_LittleE(BinaryTestData <decimal> data) => RunTest(data, new DecimalEtfConverter('e'));
 public void Number(BinaryTestData <ulong> data) => RunTest(data);
예제 #21
0
 public void Format_LittleE(BinaryTestData <float> data) => RunTest(data, new SingleEtfConverter('e'));
 public void Format_X(BinaryTestData <ulong> data) => RunTest(data, new UInt64EtfConverter('X'));
예제 #23
0
 public void Format_LittleE(BinaryTestData <double> data) => RunTest(data, new DoubleEtfConverter('e'));
 public void Format_X(BinaryTestData <byte> data) => RunTest(data, new ByteEtfConverter('X'));
예제 #25
0
 public void Format_N(BinaryTestData <Guid> data) => RunTest(data, new GuidEtfConverter('N'));
 public void Number(BinaryTestData <ushort> data) => RunTest(data);
예제 #27
0
 public void SmallAtomUtf8(BinaryTestData <bool> data) => RunTest(data);
 public void Format_X(BinaryTestData <ushort> data) => RunTest(data, new UInt16EtfConverter('X'));
예제 #29
0
 public void Format_LittleL(BinaryTestData <bool> data) => RunTest(data, new BooleanEtfConverter('l'));
예제 #30
0
 public void Format_Default(BinaryTestData <DateTimeOffset> data) => RunTest(data);