Esempio n. 1
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"));
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
        public void CheckSecondaryTypes()
        {
            var msg = new FudgeMsg(context);
            var dt = new DateTime(1987, 1, 13, 8, 6, 5);
            var dto = new DateTimeOffset(1822, 7, 20, 13, 2, 15, new TimeSpan(-2, 0, 0));

            msg.Add("dt", dt);
            msg.Add("dto", dto);

            Assert.Same(DateTimeFieldType.Instance, msg.GetByName("dt").Type);
            Assert.IsType<FudgeDateTime>(msg.GetByName("dt").Value);
            Assert.Same(DateTimeFieldType.Instance, msg.GetByName("dto").Type);
            Assert.IsType<FudgeDateTime>(msg.GetByName("dto").Value);

            Assert.Equal(dt, msg.GetValue<DateTime>("dt"));
            Assert.Equal(dto, msg.GetValue<DateTime>("dto"));
        }
        public void CheckSecondaryTypes()
        {
            var msg = new FudgeMsg(context);
            var dt  = new DateTime(1987, 1, 13, 8, 6, 5);
            var dto = new DateTimeOffset(1822, 7, 20, 13, 2, 15, new TimeSpan(-2, 0, 0));

            msg.Add("dt", dt);
            msg.Add("dto", dto);

            Assert.Same(DateTimeFieldType.Instance, msg.GetByName("dt").Type);
            Assert.IsType <FudgeDateTime>(msg.GetByName("dt").Value);
            Assert.Same(DateTimeFieldType.Instance, msg.GetByName("dto").Type);
            Assert.IsType <FudgeDateTime>(msg.GetByName("dto").Value);

            Assert.Equal(dt, msg.GetValue <DateTime>("dt"));
            Assert.Equal(dto, msg.GetValue <DateTime>("dto"));
        }
Esempio n. 6
0
        public void Minimization()
        {
            FudgeMsg msg = new FudgeMsg();

            msg.Add("int?", 17);

            Assert.Same(PrimitiveFieldTypes.SByteType, msg.GetByName("int?").Type);
        }
        public void Minimsation()
        {
            var msg = new FudgeMsg(context);
            var dt = new DateTime(1990, 2, 1);
            var fdt = new FudgeDateTime(1990, 2, 1, 0, 0, 0, 0, FudgeDateTimePrecision.Day);

            msg.Add("dt", dt);
            msg.Add("fdt", fdt);
            Assert.Same(DateFieldType.Instance, msg.GetByName("dt").Type);
            Assert.IsType<FudgeDate>(msg.GetByName("dt").Value);
            Assert.Same(DateFieldType.Instance, msg.GetByName("fdt").Type);
            Assert.IsType<FudgeDate>(msg.GetByName("fdt").Value);

            Assert.Equal(dt, msg.GetValue<DateTime>("dt"));
            Assert.Equal(fdt, msg.GetValue<FudgeDateTime>("fdt"));

            // Error cases
            FudgeFieldType type = null;
            Assert.Equal(null, DateTimeFieldType.Instance.Minimize(null, ref type));
            Assert.Throws<ArgumentException>(() => DateTimeFieldType.Instance.Minimize("fred", ref type));
        }
        public void Minimsation()
        {
            var msg = new FudgeMsg(context);
            var dt  = new DateTime(1990, 2, 1);
            var fdt = new FudgeDateTime(1990, 2, 1, 0, 0, 0, 0, FudgeDateTimePrecision.Day);

            msg.Add("dt", dt);
            msg.Add("fdt", fdt);
            Assert.Same(DateFieldType.Instance, msg.GetByName("dt").Type);
            Assert.IsType <FudgeDate>(msg.GetByName("dt").Value);
            Assert.Same(DateFieldType.Instance, msg.GetByName("fdt").Type);
            Assert.IsType <FudgeDate>(msg.GetByName("fdt").Value);

            Assert.Equal(dt, msg.GetValue <DateTime>("dt"));
            Assert.Equal(fdt, msg.GetValue <FudgeDateTime>("fdt"));

            // Error cases
            FudgeFieldType type = null;

            Assert.Equal(null, DateTimeFieldType.Instance.Minimize(null, ref type));
            Assert.Throws <ArgumentException>(() => DateTimeFieldType.Instance.Minimize("fred", ref type));
        }
Esempio n. 9
0
        public void Minimization()
        {
            FudgeMsg msg = new FudgeMsg();
            msg.Add("int?", 17);

            Assert.Same(PrimitiveFieldTypes.SByteType, msg.GetByName("int?").Type);
        }