Ejemplo n.º 1
0
        public void Serialize_WithSupportedTransaction_ShouldInvokePayloadSerializer(
            int version,
            int id,
            params byte[] expected)
        {
            // Arrange.
            var tx         = new FakeTransaction(null, null, id, version);
            var serializer = new FakeTransactionPayloadSerializer(tx.Id);
            var subject    = new TransactionSerializer(new[] { serializer });
            var writer     = new ArrayBufferWriter <byte>();

            serializer.StubbedSerialize
            .Setup(f => f(It.IsAny <IBufferWriter <byte> >(), It.IsAny <Elysium.Transaction>()))
            .Callback((IBufferWriter <byte> writer, Elysium.Transaction tx) =>
            {
                writer.Write(new ReadOnlySpan <byte>(expected, 4, expected.Length - 4));
            });

            // Act.
            subject.Serialize(writer, tx);

            // Assert.
            Assert.Equal(expected, writer.WrittenSpan.ToArray());

            serializer.StubbedSerialize.Verify(f => f(writer, tx), Times.Once());
        }
Ejemplo n.º 2
0
 public TransactionSerializerTests()
 {
     this.payload1 = new FakeTransactionPayloadSerializer(0);
     this.payload2 = new FakeTransactionPayloadSerializer(1);
     this.subject  = new TransactionSerializer(new[] { this.payload1, this.payload2 });
 }