예제 #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));
        }
예제 #2
0
        public void LookupByNameSingleValue()
        {
            FudgeMsg            msg    = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            IFudgeField         field  = null;
            IList <IFudgeField> fields = null;

            field = msg.GetByName("boolean");
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal(true, field.Value);
            Assert.Equal("boolean", field.Name);
            Assert.Null(field.Ordinal);

            field = msg.GetByName("Boolean");
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal((object)false, field.Value);
            Assert.Equal("Boolean", field.Name);
            Assert.Null(field.Ordinal);

            fields = msg.GetAllByName("boolean");
            Assert.NotNull(fields);
            Assert.Equal(1, fields.Count);
            field = fields[0];
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal(true, field.Value);
            Assert.Equal("boolean", field.Name);
            Assert.Null(field.Ordinal);

            // Check the indicator type specially
            Assert.Same(IndicatorType.Instance, msg.GetValue("indicator"));
        }
예제 #3
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"));
        }
예제 #4
0
        public void LookupByNameMultipleValues()
        {
            FudgeMsg            msg    = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            IFudgeField         field  = null;
            IList <IFudgeField> fields = null;

            // Now add a second by name.
            msg.Add("boolean", true);

            field = msg.GetByName("boolean");
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal(true, field.Value);
            Assert.Equal("boolean", field.Name);
            Assert.Null(field.Ordinal);

            fields = msg.GetAllByName("boolean");
            Assert.NotNull(fields);
            Assert.Equal(2, fields.Count);
            field = fields[0];
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal(true, field.Value);
            Assert.Equal("boolean", field.Name);
            Assert.Null(field.Ordinal);

            field = fields[1];
            Assert.NotNull(field);
            Assert.Equal(PrimitiveFieldTypes.BooleanType, field.Type);
            Assert.Equal(true, field.Value);
            Assert.Equal("boolean", field.Name);
            Assert.Null(field.Ordinal);
        }
예제 #5
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));
        }
예제 #6
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"));
        }
예제 #7
0
        public void GetValueTyped()
        {
            FudgeMsg msg       = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            long     longValue = ((long)int.MaxValue) + 5;

            Assert.Equal(longValue, msg.GetValue <long>("long"));
            Assert.Equal(5, msg.GetValue <long>("byte"));
        }
        /// <summary>
        /// Will output a <see cref="FudgeMsg"/> to <see cref="Console.Out"/> so that you can visually
        /// examine it.
        /// </summary>
        public void OutputToStdoutAllOrdinals()
        {
            Console.Out.WriteLine("FudgeMsgFormatterTest.OutputToStdoutAllOrdinals()");
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            msg.Add("Sub Message", (short)9999, StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext));
            new FudgeMsgFormatter(Console.Out).Format(msg);
        }
예제 #9
0
        public void GetMessageMethodsFRN5()
        {
            var msg = StandardFudgeMessages.CreateMessageWithSubMsgs(fudgeContext);

            Assert.Null(msg.GetMessage(42));
            Assert.Null(msg.GetMessage("No Such Field"));
            Assert.True(msg.GetMessage("sub1") is IFudgeFieldContainer);
        }
예제 #10
0
        public void ToByteArray()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);

            byte[] bytes = msg.ToByteArray();
            Assert.NotNull(bytes);
            Assert.True(bytes.Length > 10);
        }
예제 #11
0
        public void AllNames()
        {
            FudgeMsg inputMsg  = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            FudgeMsg outputMsg = CycleMessage(inputMsg);

            Assert.NotNull(outputMsg);

            FudgeUtils.AssertAllFieldsMatch(inputMsg, outputMsg);
        }
예제 #12
0
        public void SubMsg() //throws IOException
        {
            var inputMsg = StandardFudgeMessages.CreateMessageWithSubMsgs(fudgeContext);

            FudgeMsg outputMsg = CycleMessage(inputMsg);

            Assert.NotNull(outputMsg);

            FudgeUtils.AssertAllFieldsMatch(inputMsg, outputMsg);
        }
예제 #13
0
        public void AllNamesCodecNoTaxonomy()
        {
            FudgeMsg     inputMsg  = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            FudgeContext context   = new FudgeContext();
            FudgeMsg     outputMsg = CycleMessage(inputMsg, context, null);

            Assert.NotNull(outputMsg);

            FudgeUtils.AssertAllFieldsMatch(inputMsg, outputMsg);
        }
예제 #14
0
        public void IterableContainer()
        {
            IFudgeFieldContainer msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            int fieldCount           = 0;

            foreach (IFudgeField field in msg)
            {
                fieldCount++;
            }
            Assert.Equal(msg.GetNumFields(), fieldCount);
        }
예제 #15
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"));
        }
예제 #16
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));
        }
예제 #17
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"));
        }
예제 #18
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));
        }
예제 #19
0
        public void AllMessagesSameContext()
        {
            FudgeContext fudgeContext = new FudgeContext();
            FudgeMsg     msg          = null;

            msg = StandardFudgeMessages.CreateMessageAllNames(fudgeContext);
            CheckResultsMatch(msg, fudgeContext);
            msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);
            CheckResultsMatch(msg, fudgeContext);
            msg = StandardFudgeMessages.CreateMessageAllByteArrayLengths(fudgeContext);
            CheckResultsMatch(msg, fudgeContext);
            msg = StandardFudgeMessages.CreateMessageWithSubMsgs(fudgeContext);
            CheckResultsMatch(msg, fudgeContext);
            msg = StandardFudgeMessages.CreateLargeMessage(fudgeContext);
            CheckResultsMatch(msg);
        }
예제 #20
0
        public void FixedLengthByteArrays()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllByteArrayLengths(fudgeContext);

            Assert.Same(ByteArrayFieldType.Length4Instance, msg.GetByName("byte[4]").Type);
            Assert.Same(ByteArrayFieldType.Length8Instance, msg.GetByName("byte[8]").Type);
            Assert.Same(ByteArrayFieldType.Length16Instance, msg.GetByName("byte[16]").Type);
            Assert.Same(ByteArrayFieldType.Length20Instance, msg.GetByName("byte[20]").Type);
            Assert.Same(ByteArrayFieldType.Length32Instance, msg.GetByName("byte[32]").Type);
            Assert.Same(ByteArrayFieldType.Length64Instance, msg.GetByName("byte[64]").Type);
            Assert.Same(ByteArrayFieldType.Length128Instance, msg.GetByName("byte[128]").Type);
            Assert.Same(ByteArrayFieldType.Length256Instance, msg.GetByName("byte[256]").Type);
            Assert.Same(ByteArrayFieldType.Length512Instance, msg.GetByName("byte[512]").Type);

            Assert.Same(ByteArrayFieldType.VariableSizedInstance, msg.GetByName("byte[28]").Type);
        }
예제 #21
0
        public void LargeMessage()
        { // FRN-91
            FudgeMsg msg = StandardFudgeMessages.CreateLargeMessage(fudgeContext);

            CheckResultsMatch(msg);
        }
예제 #22
0
        public void StandardMessageSubMessages()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageWithSubMsgs(fudgeContext);

            CheckResultsMatch(msg);
        }
예제 #23
0
        public void StandardMessageByteArrays()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllByteArrayLengths(fudgeContext);

            CheckResultsMatch(msg);
        }
예제 #24
0
        public void StandardMessageAllOrdinals()
        {
            FudgeMsg msg = StandardFudgeMessages.CreateMessageAllOrdinals(fudgeContext);

            CheckResultsMatch(msg);
        }