public void TestDecodeMessageWithAllFieldTypes() { // --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6--- const string msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010"; Stream input = ByteUtil.CreateByteStream(msgstr); var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("4", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("5", FASTType.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("6", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false), }); var context = new Context(); context.RegisterTemplate(113, template); GroupValue message = new Message(template); message.SetString(1, "H"); message.SetByteVector(2, new[] { (byte)0xFF }); message.SetDecimal(3, 1.201); message.SetInteger(4, -1); message.SetString(5, "abc"); message.SetInteger(6, 2); Assert.AreEqual(message, new FastDecoder(context, input).ReadMessage()); }
public void TestEncodeMessageWithAllFieldTypes() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("4", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("5", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("6", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false), }); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetString(1, "H"); message.SetByteVector(2, new[] { (byte)0xFF }); message.SetDecimal(3, 1.201); message.SetInteger(4, -1); message.SetString(5, "abc"); message.SetInteger(6, 2); // --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6--- const string msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010"; AssertEquals(msgstr, new FastEncoder(context).Encode(message)); }
public void SetUp() { output = new PipedStream(); input = new PipedStream(output); encodingContext = new Context(); decodingContext = new Context(); encoder = new FastEncoder(encodingContext); decoder = new FastDecoder(decodingContext, input); }
public void TestDecodeEmptyMessage() { var messageTemplate = new MessageTemplate("", new Field[] { }); Stream input = ByteUtil.CreateByteStream("11000000 11110001"); var context = new Context(); context.RegisterTemplate(113, messageTemplate); Message message = new FastDecoder(context, input).ReadMessage(); Assert.AreEqual(113, message.GetInt(0)); }
public void TestEncodeEmptyMessage() { var messageTemplate = new MessageTemplate("", new Field[] { }); var message = new Message(messageTemplate); var context = new Context(); context.RegisterTemplate(113, messageTemplate); byte[] encoding = new FastEncoder(context).Encode(message); AssertEquals("11000000 11110001", encoding); }
public void TestLookup() { ObjectMother.AllocationInstruction().TypeReference = new QName("AllocationInstruction"); ObjectMother.Allocations().TypeReference = new QName("Allocation"); var context = new Context(); context.Store("type", ObjectMother.AllocationInstruction(), new QName("ID"), String("1234")); Assert.AreEqual(String("1234"), context.Lookup("type", ObjectMother.AllocationInstruction(), new QName("ID"))); Assert.AreEqual(ScalarValue.UNDEFINED, context.Lookup("type", ObjectMother.Allocations().Group, new QName("ID"))); }
public void testDecodeSimpleMessage() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false) }); Stream input = ByteUtil.CreateByteStream("11100000 11110001 10000001"); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetInteger(1, 1); var decoder = new FastDecoder(context, input); GroupValue readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); Assert.AreEqual(readMessage, message); }
public void TestDecodeSequentialEmptyMessages() { var messageTemplate = new MessageTemplate("", new Field[] { }); Stream input = ByteUtil.CreateByteStream("11000000 11110001 10000000"); var context = new Context(); context.RegisterTemplate(113, messageTemplate); var decoder = new FastDecoder(context, input); GroupValue message = decoder.ReadMessage(); GroupValue message2 = decoder.ReadMessage(); Assert.AreEqual(113, message.GetInt(0)); Assert.AreEqual(113, message2.GetInt(0)); }
public void testDecodeMessageWithStringFieldTypesAndAllOperators() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.ASCII, Operator.DELTA, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.ASCII, Operator.CONSTANT, new StringValue("e"), false), /* NON-TRANSFERRABLE */ new Scalar("4", FASTType.ASCII, Operator.DEFAULT, new StringValue("long"), false) }); var message = new Message(template); message.SetString(1, "on"); message.SetString(2, "DCB32"); message.SetString(3, "e"); message.SetString(4, "long"); // --PMAP-- --TID--- --------#1------- ---------------------#2--------------------- const string msg1 = "11100000 11110001 01101111 11101110 10000000 01000100 01000011 01000010 00110011 10110010"; // --PMAP-- ------------#2------------ ---------------------#4--------------------- const string msg2 = "10010000 10000010 00110001 10110110 01110011 01101000 01101111 01110010 11110100"; Stream input = ByteUtil.CreateByteStream(msg1 + ' ' + msg2); var context = new Context(); context.RegisterTemplate(113, template); var decoder = new FastDecoder(context, input); Message readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetString(2, "DCB16"); message.SetString(4, "short"); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); }
public void TestEncodeMessageWithStringFieldTypesAndAllOperators() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.STRING, Operator.DELTA, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.STRING, Operator.CONSTANT, new StringValue("e"), false), /* NON-TRANSFERRABLE */ new Scalar("4", FASTType.STRING, Operator.DEFAULT, new StringValue("long"), false) }); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetString(1, "on"); message.SetString(2, "DCB32"); message.SetString(3, "e"); message.SetString(4, "long"); // --PMAP-- --TID--- --------#1------- ---------------------#2------------------------------ const string msg1 = "11100000 11110001 01101111 11101110 10000000 01000100 01000011 01000010 00110011 10110010"; // --PMAP-- --------#2---------------- ---------------------#4--------------------- const string msg2 = "10010000 10000010 00110001 10110110 01110011 01101000 01101111 01110010 11110100"; var encoder = new FastEncoder(context); AssertEquals(msg1, encoder.Encode(message)); message.SetString(2, "DCB16"); message.SetString(4, "short"); AssertEquals(msg2, encoder.Encode(message)); }
protected static FastDecoder Decoder(String bitString, MessageTemplate template) { var context = new Context(); context.RegisterTemplate(1, template); return new FastDecoder(context, BitStream(bitString)); }
public void TestEncodeMessageWithOverlongPmap() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false), new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false) }); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetInteger(1, 1); message.SetInteger(2, 1); message.SetInteger(3, 1); message.SetInteger(4, 1); message.SetInteger(5, 1); message.SetInteger(6, 1); message.SetInteger(7, 1); // --PMAP-- --PMAP-- --PMAP-- --TID--- //WHAT IT THINKS 01000000 00000000 10000000 11110001 const string msgstr = "11000000 11110001"; AssertEquals(msgstr, new FastEncoder(context).Encode(message)); }
public void TestEncodeSimpleMessage() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false) }); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetInteger(1, 1); var encoder = new FastEncoder(context); AssertEquals("11100000 11110001 10000001", encoder.Encode(message)); }
public void TestEncodeSequentialEmptyMessages() { var messageTemplate = new MessageTemplate("", new Field[] { }); var message = new Message(messageTemplate); var nextMsg = new Message(messageTemplate); var context = new Context(); context.RegisterTemplate(113, messageTemplate); var encoder = new FastEncoder(context); // Presence map should show that the only field present is the template id. AssertEquals("11000000 11110001", encoder.Encode(message)); // Presence map should be empty (except for leading stop bit) AssertEquals("10000000", encoder.Encode(nextMsg)); }
public void TestEncodeMessageWithUnsignedIntegerFieldTypesAndAllOperators() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.U32, Operator.DELTA, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.I32, Operator.INCREMENT, new IntegerValue(10), false), new Scalar("4", FASTType.I32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), new Scalar("5", FASTType.I32, Operator.CONSTANT, new IntegerValue(1), false), /* NON-TRANSFERRABLE */ new Scalar("6", FASTType.I32, Operator.DEFAULT, new IntegerValue(2), false) }); var context = new Context(); context.RegisterTemplate(113, template); var encoder = new FastEncoder(context); var message = new Message(template); message.SetInteger(1, 109); message.SetInteger(2, 29470); message.SetInteger(3, 10); message.SetInteger(4, 3); message.SetInteger(5, 1); message.SetInteger(6, 2); // --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4--- const string msg1 = "11101000 11110001 11101101 00000001 01100110 10011110 10000011"; AssertEquals(msg1, encoder.Encode(message)); message.SetInteger(2, 29471); message.SetInteger(3, 11); message.SetInteger(4, 4); message.SetInteger(6, 3); // --PMAP-- ---#2--- ---#6--- const string msg2 = "10000100 10000001 10000011"; AssertEquals(msg2, encoder.Encode(message)); message.SetInteger(1, 96); message.SetInteger(2, 30500); message.SetInteger(3, 12); message.SetInteger(4, 1); // --PMAP-- ---#1--- --------#2------- ---#4--- ---#6--- const string msg3 = "10101100 11100000 00001000 10000101 10000001 10000011"; AssertEquals(msg3, encoder.Encode(message)); }
protected static FastDecoder Decoder(MessageTemplate template, byte[] encoding) { var context = new Context(); context.RegisterTemplate(1, template); return new FastDecoder(context, new MemoryStream(encoding)); }
public void TestDecodeMessageWithSignedIntegerFieldTypesAndAllOperators() { var template = new MessageTemplate("", new Field[] { new Scalar("1", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false), new Scalar("2", FASTType.I32, Operator.DELTA, ScalarValue.UNDEFINED, false), new Scalar("3", FASTType.I32, Operator.INCREMENT, new IntegerValue(10), false), new Scalar("4", FASTType.I32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), new Scalar("5", FASTType.I32, Operator.CONSTANT, new IntegerValue(1), false), /* NON-TRANSFERRABLE */ new Scalar("6", FASTType.I32, Operator.DEFAULT, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.SetInteger(1, 109); message.SetInteger(2, 29470); message.SetInteger(3, 10); message.SetInteger(4, 3); message.SetInteger(5, 1); message.SetInteger(6, 2); // --PMAP-- --TID--- --------#1------- ------------#2------------ ---#4--- const string msg1 = "11101000 11110001 00000000 11101101 00000001 01100110 10011110 10000011"; // --PMAP-- ---#2--- ---#6--- const string msg2 = "10000100 11111111 10000011"; // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- const string msg3 = "10101100 00000000 11100000 00001000 10000111 10000001 10000011"; Stream input = ByteUtil.CreateByteStream(msg1 + ' ' + msg2 + ' ' + msg3); var context = new Context(); context.RegisterTemplate(113, template); var decoder = new FastDecoder(context, input); Message readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetInteger(2, 29469); message.SetInteger(3, 11); message.SetInteger(4, 4); message.SetInteger(6, 3); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetInteger(1, 96); message.SetInteger(2, 30500); message.SetInteger(3, 12); message.SetInteger(4, 1); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); }
protected static FastEncoder Encoder(MessageTemplate template) { var context = new Context(); context.RegisterTemplate(1, template); return new FastEncoder(context); }
public MessageInputStream(Stream inputStream, Context context) { _inStream = inputStream; _context = context; _decoder = new FastDecoder(context, _inStream); }
public MessageInputStream(System.IO.Stream inputStream, Context context) { in_Renamed = inputStream; this.context = context; decoder = new FastDecoder(context, in_Renamed); }
public MessageOutputStream(System.IO.Stream outputStream, Context context) { out_Renamed = outputStream; encoder = new FastEncoder(context); this.context = context; }
public MessageOutputStream(Stream outputStream, Context context) { _outStream = outputStream; _encoder = new FastEncoder(context); _context = context; }