Exemplo n.º 1
0
        public void PrimitiveExactQueriesOrdinalsMatch()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            Assert.Equal((sbyte)5, msg.GetSByte((short)3));
            Assert.Equal((sbyte)5, msg.GetSByte((short)4));

            short shortValue = ((short)sbyte.MaxValue) + 5;

            Assert.Equal(shortValue, msg.GetShort((short)5));
            Assert.Equal(shortValue, msg.GetShort((short)6));

            int intValue = ((int)short.MaxValue) + 5;

            Assert.Equal(intValue, msg.GetInt((short)7));
            Assert.Equal(intValue, msg.GetInt((short)8));

            long longValue = ((long)int.MaxValue) + 5;

            Assert.Equal(longValue, msg.GetLong((short)9));
            Assert.Equal(longValue, msg.GetLong((short)10));

            Assert.Equal(0.5f, msg.GetFloat((short)11));
            Assert.Equal(0.5f, msg.GetFloat((short)12));
            Assert.Equal(0.27362, msg.GetDouble((short)13));
            Assert.Equal(0.27362, msg.GetDouble((short)14));

            Assert.Equal("Kirk Wylie", msg.GetString((short)15));
        }
Exemplo n.º 2
0
        public void PrimitiveExactQueriesNamesMatch()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);

            Assert.Equal((sbyte)5, msg.GetSByte("byte"));
            Assert.Equal((sbyte)5, msg.GetSByte("Byte"));

            short shortValue = ((short)sbyte.MaxValue) + 5;

            Assert.Equal(shortValue, msg.GetShort("short"));
            Assert.Equal(shortValue, msg.GetShort("Short"));

            int intValue = ((int)short.MaxValue) + 5;

            Assert.Equal(intValue, msg.GetInt("int"));
            Assert.Equal(intValue, msg.GetInt("Integer"));

            long longValue = ((long)int.MaxValue) + 5;

            Assert.Equal(longValue, msg.GetLong("long"));
            Assert.Equal(longValue, msg.GetLong("Long"));

            Assert.Equal(0.5f, msg.GetFloat("float"));
            Assert.Equal(0.5f, msg.GetFloat("Float"));
            Assert.Equal(0.27362, msg.GetDouble("double"));
            Assert.Equal(0.27362, msg.GetDouble("Double"));

            Assert.Equal("Kirk Wylie", msg.GetString("String"));
        }
Exemplo n.º 3
0
        public void LongInLongOut()
        {
            FudgeMsg msg = new FudgeMsg();

            msg.Add("test", (long)5);
            Assert.Equal((long)5, msg.GetLong("test"));
        }
Exemplo n.º 4
0
        public void PrimitiveExactQueriesOrdinalsNoMatch()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            Assert.Throws <OverflowException>(() => msg.GetSByte(7));
            Assert.Throws <OverflowException>(() => msg.GetShort(7));
            Assert.Throws <OverflowException>(() => msg.GetInt(9));
            Assert.Equal(((long)short.MaxValue) + 5, msg.GetLong(7));
            Assert.Equal(0.27362f, msg.GetFloat(13));
            Assert.Equal(0.5, msg.GetDouble(11));
        }
Exemplo n.º 5
0
        public void PrimitiveExactQueriesNamesNoMatch()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);

            Assert.Throws <OverflowException>(() => msg.GetSByte("int"));
            Assert.Throws <OverflowException>(() => msg.GetShort("int"));
            Assert.Equal(5, msg.GetInt("byte"));
            Assert.Equal(((long)short.MaxValue) + 5, msg.GetLong("int"));
            Assert.Equal(0.27362f, msg.GetFloat("double"));
            Assert.Equal(0.5, msg.GetDouble("float"));
        }
Exemplo n.º 6
0
        public void PrimitiveExactOrdinalsNoOrdinals()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            Assert.Null(msg.GetSByte((short)100));
            Assert.Null(msg.GetShort((short)100));
            Assert.Null(msg.GetInt((short)100));
            Assert.Null(msg.GetLong((short)100));
            Assert.Null(msg.GetFloat((short)100));
            Assert.Null(msg.GetDouble((short)100));
            Assert.Null(msg.GetString((short)100));
        }
Exemplo n.º 7
0
        public void PrimitiveExactQueriesNoNames()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);

            Assert.Null(msg.GetSByte("foobar"));
            Assert.Null(msg.GetShort("foobar"));
            Assert.Null(msg.GetInt("foobar"));
            Assert.Null(msg.GetLong("foobar"));
            Assert.Null(msg.GetFloat("foobar"));
            Assert.Null(msg.GetDouble("foobar"));
            Assert.Null(msg.GetString("foobar"));
        }
Exemplo n.º 8
0
        public void LongInLongOut()
        {
            FudgeMsg msg = new FudgeMsg();

            msg.Add("test", (long)5);
            Assert.Equal((long)5, msg.GetLong("test"));
        }
        private static int FudgeCycle(bool useNames, bool useOrdinals)
        {
            MemoryStream outputStream = new MemoryStream();
            var bw = new FudgeBinaryWriter(outputStream);
            SmallFinancialTick tick = new SmallFinancialTick();
            FudgeMsg msg = new FudgeMsg(fudgeContext);
            if (useNames && useOrdinals)
            {
                msg.Add("ask", (short)1, tick.Ask);
                msg.Add("askVolume", (short)2, tick.AskVolume);
                msg.Add("bid", (short)3, tick.Bid);
                msg.Add("bidVolume", (short)4, tick.BidVolume);
                msg.Add("ts", (short)5, tick.Timestamp);
            }
            else if (useNames)
            {
                msg.Add("ask", tick.Ask);
                msg.Add("askVolume", tick.AskVolume);
                msg.Add("bid", tick.Bid);
                msg.Add("bidVolume", tick.BidVolume);
                msg.Add("ts", tick.Timestamp);
            }
            else if (useOrdinals)
            {
                msg.Add(1, tick.Ask);
                msg.Add(2, tick.AskVolume);
                msg.Add(3, tick.Bid);
                msg.Add(4, tick.BidVolume);
                msg.Add(5, tick.Timestamp);
            }
            fudgeContext.Serialize(msg, bw);

            byte[] data = outputStream.ToArray();

            MemoryStream inputstream = new MemoryStream(data);
            var br = new FudgeBinaryReader(inputstream);
            msg = fudgeContext.Deserialize(inputstream).Message;

            tick = new SmallFinancialTick();
            if (useOrdinals)
            {
                tick.Ask = msg.GetDouble(1).Value;
                tick.AskVolume = msg.GetDouble(2).Value;
                tick.Bid = msg.GetDouble(3).Value;
                tick.BidVolume = msg.GetDouble(4).Value;
                tick.Timestamp = msg.GetLong(5).Value;
            }
            else if (useNames)
            {
                tick.Ask = msg.GetDouble("ask").Value;
                tick.AskVolume = msg.GetDouble("askVolume").Value;
                tick.Bid = msg.GetDouble("bid").Value;
                tick.BidVolume = msg.GetDouble("bidVolume").Value;
                tick.Timestamp = msg.GetLong("ts").Value;
            }
            else
            {
                throw new InvalidOperationException("Names or ordinals, pick at least one.");
            }
            return data.Length;
        }
Exemplo n.º 10
0
        private static int FudgeCycle(bool useNames, bool useOrdinals)
        {
            MemoryStream       outputStream = new MemoryStream();
            var                bw           = new FudgeBinaryWriter(outputStream);
            SmallFinancialTick tick         = new SmallFinancialTick();
            FudgeMsg           msg          = new FudgeMsg(fudgeContext);

            if (useNames && useOrdinals)
            {
                msg.Add("ask", (short)1, tick.Ask);
                msg.Add("askVolume", (short)2, tick.AskVolume);
                msg.Add("bid", (short)3, tick.Bid);
                msg.Add("bidVolume", (short)4, tick.BidVolume);
                msg.Add("ts", (short)5, tick.Timestamp);
            }
            else if (useNames)
            {
                msg.Add("ask", tick.Ask);
                msg.Add("askVolume", tick.AskVolume);
                msg.Add("bid", tick.Bid);
                msg.Add("bidVolume", tick.BidVolume);
                msg.Add("ts", tick.Timestamp);
            }
            else if (useOrdinals)
            {
                msg.Add(1, tick.Ask);
                msg.Add(2, tick.AskVolume);
                msg.Add(3, tick.Bid);
                msg.Add(4, tick.BidVolume);
                msg.Add(5, tick.Timestamp);
            }
            fudgeContext.Serialize(msg, bw);

            byte[] data = outputStream.ToArray();

            MemoryStream inputstream = new MemoryStream(data);
            var          br          = new FudgeBinaryReader(inputstream);

            msg = fudgeContext.Deserialize(inputstream).Message;

            tick = new SmallFinancialTick();
            if (useOrdinals)
            {
                tick.Ask       = msg.GetDouble(1).Value;
                tick.AskVolume = msg.GetDouble(2).Value;
                tick.Bid       = msg.GetDouble(3).Value;
                tick.BidVolume = msg.GetDouble(4).Value;
                tick.Timestamp = msg.GetLong(5).Value;
            }
            else if (useNames)
            {
                tick.Ask       = msg.GetDouble("ask").Value;
                tick.AskVolume = msg.GetDouble("askVolume").Value;
                tick.Bid       = msg.GetDouble("bid").Value;
                tick.BidVolume = msg.GetDouble("bidVolume").Value;
                tick.Timestamp = msg.GetLong("ts").Value;
            }
            else
            {
                throw new InvalidOperationException("Names or ordinals, pick at least one.");
            }
            return(data.Length);
        }
Exemplo n.º 11
0
        public void AsQueriesToLongOrdinals()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            Assert.Equal((long)((sbyte)5), msg.GetLong((short)3));
            Assert.Equal((long)((sbyte)5), msg.GetLong((short)4));

            short shortValue = ((short)sbyte.MaxValue) + 5;

            Assert.Equal((long)(shortValue), msg.GetLong((short)5));
            Assert.Equal((long)(shortValue), msg.GetLong((short)6));

            int intValue = ((int)short.MaxValue) + 5;

            Assert.Equal((long)(intValue), msg.GetLong((short)7));
            Assert.Equal((long)(intValue), msg.GetLong((short)8));

            long longValue = ((long)int.MaxValue) + 5;

            Assert.Equal(longValue, msg.GetLong((short)9));
            Assert.Equal(longValue, msg.GetLong((short)10));

            Assert.Equal(0, msg.GetLong((short)11));
            Assert.Equal(0, msg.GetLong((short)12));
            Assert.Equal(0, msg.GetLong((short)13));
            Assert.Equal(0, msg.GetLong((short)14));
        }
Exemplo n.º 12
0
        public void AsQueriesToLongNames()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);

            Assert.Equal((long?)((sbyte)5), msg.GetLong("byte"));
            Assert.Equal((long?)((sbyte)5), msg.GetLong("Byte"));


            short shortValue = ((short)sbyte.MaxValue) + 5;

            Assert.Equal((long?)(shortValue), msg.GetLong("short"));
            Assert.Equal((long?)(shortValue), msg.GetLong("Short"));

            int intValue = ((int)short.MaxValue) + 5;

            Assert.Equal((long?)(intValue), msg.GetLong("int"));
            Assert.Equal((long?)(intValue), msg.GetLong("Integer"));

            long longValue = ((long)int.MaxValue) + 5;

            Assert.Equal((long?)(longValue), msg.GetLong("long"));
            Assert.Equal((long?)(longValue), msg.GetLong("Long"));

            Assert.Equal((long?)(0), msg.GetLong("float"));
            Assert.Equal((long?)(0), msg.GetLong("Float"));
            Assert.Equal((long?)(0), msg.GetLong("double"));
            Assert.Equal((long?)(0), msg.GetLong("Double"));
        }