Exemple #1
0
        public void Deserialize_ThrowsExecption_IfMessageIsNothaveValidType()
        {
            var       bytes = new byte[15];
            Exception ex    = Assert.Throws <Exception>(() => OrderTriggerSerializer.Deserialize(bytes));

            Assert.Equal(Types.Constant.INVALID_MESSAGE, ex.Message);
        }
Exemple #2
0
        public void Deserialize_ThrowsExecption_IfMessageIsNothaveValidType()
        {
            var       bytes = new byte[15];
            Exception ex    = Assert.Throws <Exception>(() => OrderTriggerSerializer.Deserialize(bytes));

            Assert.Equal("Invalid Message", ex.Message);
        }
Exemple #3
0
        public void Deserialize_ThrowsExecption_IfMessageIsGreaterThan35Bytes()
        {
            var       bytes = new byte[16];
            Exception ex    = Assert.Throws <Exception>(() => OrderTriggerSerializer.Deserialize(bytes));

            Assert.Equal("Order Trigger Message must be of Size : 15", ex.Message);
        }
Exemple #4
0
        private void OnMessage(byte[] body)
        {
            var    type = Serializer.GetMessageType(body);
            object obj  = null;

            switch (type)
            {
            case MessageType.Cancel:
                obj = CancelledOrderSerializer.Deserialize(body);
                break;

            case MessageType.Fill:
                obj = FillSerializer.Deserialize(body);
                break;

            case MessageType.OrderTrigger:
                obj = OrderTriggerSerializer.Deserialize(body);
                break;

            default:
                //TODO
                break;
            }
            var message = new Message(type.Value, body, obj);

            _inboundChannelWritter.TryWrite(message);
        }
Exemple #5
0
        public void Deserialize_ThrowsExecption_IfVersionIsNotSet()
        {
            var bytes = new byte[15];

            bytes[4] = (byte)MessageType.OrderTrigger;
            Exception ex = Assert.Throws <Exception>(() => OrderTriggerSerializer.Deserialize(bytes));

            Assert.Equal(Types.Constant.INVALID_VERSION, ex.Message);
        }
Exemple #6
0
        public void Deserialize_ThrowsExecption_IfVersionIsNotSet()
        {
            var bytes = new byte[15];

            bytes[4] = (byte)MessageType.OrderTrigger;
            Exception ex = Assert.Throws <Exception>(() => OrderTriggerSerializer.Deserialize(bytes));

            Assert.Equal("version mismatch", ex.Message);
        }
Exemple #7
0
        public void Deserialize_Doesnotthrowexception_Max()
        {
            var bytes = OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = OrderId.MaxValue, Timestamp = int.MaxValue
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(15, messageLength);
            var orderTrigger = OrderTriggerSerializer.Deserialize(bytes);

            Assert.Equal(OrderId.MaxValue, orderTrigger.OrderId);
            Assert.Equal(int.MaxValue, orderTrigger.Timestamp);
        }
Exemple #8
0
        public void Deserialize_Doesnotthrowexception()
        {
            var bytes = OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 12345678, Timestamp = 404
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(15, messageLength);
            var orderTrigger = OrderTriggerSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, orderTrigger.OrderId);
            Assert.Equal(404, orderTrigger.Timestamp);
        }
        public void Deserialize_Doesnotthrowexception_Min()
        {
            var bytes = OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = ulong.MinValue, Timestamp = long.MinValue
            });
            var messageLength = BitConverter.ToInt32(bytes, 0);

            Assert.Equal(23, messageLength);
            var orderTrigger = OrderTriggerSerializer.Deserialize(bytes);

            Assert.Equal(ulong.MinValue, orderTrigger.OrderId);
            Assert.Equal(long.MinValue, orderTrigger.Timestamp);
        }
Exemple #10
0
        public void Deserialize_Doesnotthrowexception_Min()
        {
            Span <byte> bytes = stackalloc byte[OrderTriggerSerializer.MessageSize];

            OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = OrderId.MinValue, Timestamp = int.MinValue
            }, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(15, messageLength);
            var orderTrigger = OrderTriggerSerializer.Deserialize(bytes);

            Assert.Equal(OrderId.MinValue, orderTrigger.OrderId);
            Assert.Equal(int.MinValue, orderTrigger.Timestamp);
        }
        public void Deserialize_Doesnotthrowexception()
        {
            Span <byte> bytes = stackalloc byte[OrderTriggerSerializer.MessageSize];

            OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 12345678, Timestamp = 404, MessageSequence = 972
            }, bytes);
            var messageLength = BitConverter.ToInt32(bytes.Slice(0));

            Assert.Equal(23, messageLength);
            var orderTrigger = OrderTriggerSerializer.Deserialize(bytes);

            Assert.Equal((OrderId)12345678, orderTrigger.OrderId);
            Assert.Equal(404, orderTrigger.Timestamp);
            Assert.Equal(972, orderTrigger.MessageSequence);
        }
Exemple #12
0
        public void Deserialize_ThrowsExecption_IfNullPassed()
        {
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => OrderTriggerSerializer.Deserialize(null));

            Assert.Equal("bytes", ex.ParamName);
        }
 public void orderTriggerBinaryDeserialize()
 {
     var trigger = OrderTriggerSerializer.Deserialize(orderTriggerBinary);
 }
Exemple #14
0
 public void OrderTriggerBinaryDeserialize()
 {
     OrderTriggerSerializer.Deserialize(orderTriggerBinary);
 }