From b6ab1b5055ddbf3fb443da0e23a006e06444550d Mon Sep 17 00:00:00 2001 From: Grant Birchmeier Date: Wed, 25 Sep 2024 13:32:46 -0500 Subject: [PATCH 1/2] cleanup IField-derived classes --- Examples/Executor/Executor.cs | 36 +- QuickFIXn/DefaultMessageFactory.cs | 4 +- QuickFIXn/Fields/BooleanField.cs | 46 +- QuickFIXn/Fields/CharField.cs | 38 +- QuickFIXn/Fields/DateTimeField.cs | 20 +- QuickFIXn/Fields/DecimalField.cs | 11 +- QuickFIXn/Fields/FieldBase.cs | 145 +++--- QuickFIXn/Fields/IField.cs | 29 +- QuickFIXn/Fields/IntField.cs | 38 +- QuickFIXn/Fields/StringField.cs | 11 +- QuickFIXn/Fields/ULongField.cs | 11 +- QuickFIXn/Message/FieldMap.cs | 60 ++- QuickFIXn/Message/Message.cs | 28 +- QuickFIXn/MessageBuilder.cs | 4 +- QuickFIXn/Session.cs | 12 +- QuickFIXn/SessionFactory.cs | 6 +- RELEASE_NOTES.md | 4 + UnitTests/DataDictionaryTests.cs | 2 +- UnitTests/DataDictionary_ValidateTests.cs | 4 +- UnitTests/FieldMapTests.cs | 257 ++++++----- UnitTests/FieldTests.cs | 94 ++-- UnitTests/GenMessageTest.cs | 76 ++-- UnitTests/GroupTests.cs | 4 +- UnitTests/MessageTests.cs | 521 +++++++++++----------- UnitTests/SessionTest.cs | 505 ++++++++++----------- 25 files changed, 937 insertions(+), 1029 deletions(-) diff --git a/Examples/Executor/Executor.cs b/Examples/Executor/Executor.cs index 43ad84698..8e0a0b739 100644 --- a/Examples/Executor/Executor.cs +++ b/Examples/Executor/Executor.cs @@ -52,7 +52,7 @@ public void OnMessage(QuickFix.FIX40.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -105,7 +105,7 @@ public void OnMessage(QuickFix.FIX41.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -160,7 +160,7 @@ public void OnMessage(QuickFix.FIX42.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -215,7 +215,7 @@ public void OnMessage(QuickFix.FIX43.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -270,7 +270,7 @@ public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -325,7 +325,7 @@ public void OnMessage(QuickFix.FIX50.NewOrderSingle n, SessionID s) { case OrdType.LIMIT: price = n.Price; - if (price.Obj == 0) + if (price.Value == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; @@ -375,7 +375,7 @@ public void OnMessage(QuickFix.FIX50.News n, SessionID s) { } public void OnMessage(QuickFix.FIX40.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); ocj.Text = new Text("Executor does not support order cancels"); @@ -392,7 +392,7 @@ public void OnMessage(QuickFix.FIX40.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX41.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -410,7 +410,7 @@ public void OnMessage(QuickFix.FIX41.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX42.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -428,7 +428,7 @@ public void OnMessage(QuickFix.FIX42.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX43.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -446,7 +446,7 @@ public void OnMessage(QuickFix.FIX43.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); @@ -464,7 +464,7 @@ public void OnMessage(QuickFix.FIX44.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX50.OrderCancelRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); @@ -484,7 +484,7 @@ public void OnMessage(QuickFix.FIX50.OrderCancelRequest msg, SessionID s) public void OnMessage(QuickFix.FIX40.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX40.OrderCancelReject ocj = new QuickFix.FIX40.OrderCancelReject(new OrderID(orderid), msg.ClOrdID); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); ocj.Text = new Text("Executor does not support order cancel/replaces"); @@ -501,7 +501,7 @@ public void OnMessage(QuickFix.FIX40.OrderCancelReplaceRequest msg, SessionID s) public void OnMessage(QuickFix.FIX41.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX41.OrderCancelReject ocj = new QuickFix.FIX41.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -519,7 +519,7 @@ public void OnMessage(QuickFix.FIX41.OrderCancelReplaceRequest msg, SessionID s) public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX42.OrderCancelReject ocj = new QuickFix.FIX42.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -537,7 +537,7 @@ public void OnMessage(QuickFix.FIX42.OrderCancelReplaceRequest msg, SessionID s) public void OnMessage(QuickFix.FIX43.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX43.OrderCancelReject ocj = new QuickFix.FIX43.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.UNKNOWN_ORDER); @@ -555,7 +555,7 @@ public void OnMessage(QuickFix.FIX43.OrderCancelReplaceRequest msg, SessionID s) public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); @@ -573,7 +573,7 @@ public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s) public void OnMessage(QuickFix.FIX50.OrderCancelReplaceRequest msg, SessionID s) { - string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID"; + string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Value : "unknown orderID"; QuickFix.FIX50.OrderCancelReject ocj = new QuickFix.FIX50.OrderCancelReject( new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST)); ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER); diff --git a/QuickFIXn/DefaultMessageFactory.cs b/QuickFIXn/DefaultMessageFactory.cs index 1a80c9a4e..720013ac6 100644 --- a/QuickFIXn/DefaultMessageFactory.cs +++ b/QuickFIXn/DefaultMessageFactory.cs @@ -68,7 +68,7 @@ public Message Create(string beginString, QuickFix.Fields.ApplVerID applVerId, s if (beginString == QuickFix.Values.BeginString_FIXT11 && !Message.IsAdminMsgType(msgType)) { _factories.TryGetValue( - QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Obj), + QuickFix.FixValues.ApplVerID.ToBeginString(applVerId.Value), out messageFactory); } @@ -85,7 +85,7 @@ public Group Create(string beginString, string msgType, int groupCounterTag) { string key = beginString; if(beginString.Equals(FixValues.BeginString.FIXT11)) - key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.getValue()); + key = QuickFix.FixValues.ApplVerID.ToBeginString(_defaultApplVerId.Value); if (_factories.TryGetValue(key, out IMessageFactory? factory)) return factory.Create(beginString, msgType, groupCounterTag); diff --git a/QuickFIXn/Fields/BooleanField.cs b/QuickFIXn/Fields/BooleanField.cs index 56909b64e..3097138b3 100644 --- a/QuickFIXn/Fields/BooleanField.cs +++ b/QuickFIXn/Fields/BooleanField.cs @@ -1,37 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +namespace QuickFix.Fields; -namespace QuickFix.Fields -{ - /// - /// FIX BooleanField class - /// - public class BooleanField : FieldBase - { - public BooleanField(int tag) - : base(tag, false) { } - - public BooleanField(int tag, Boolean b) - : base(tag, b) { } - - /// - /// quickfix-cpp compat - returns base type - /// - /// Boolean object - public Boolean getValue() - { return Obj; } +/// +/// FIX Boolean field +/// +public class BooleanField : FieldBase { + public BooleanField(int tag) + : base(tag, false) { + } - /// - /// quickfix-cpp compat - set object - /// - public void setValue(Boolean b) - { Obj = b; } + public BooleanField(int tag, bool b) + : base(tag, b) { + } - protected override string makeString() - { - return Converters.BoolConverter.Convert(Obj); - } + protected override string MakeString() { + return Converters.BoolConverter.Convert(Value); } } + diff --git a/QuickFIXn/Fields/CharField.cs b/QuickFIXn/Fields/CharField.cs index 99556cbfc..70e30d37c 100644 --- a/QuickFIXn/Fields/CharField.cs +++ b/QuickFIXn/Fields/CharField.cs @@ -1,30 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Text; +namespace QuickFix.Fields; -namespace QuickFix.Fields -{ - /// - /// A character message field - /// - public class CharField : FieldBase - { - public CharField(int tag) - :base(tag, '\0') {} - - public CharField(int tag, char c) - : base(tag, c) { } - - // quickfix compat - public char getValue() - { return Obj; } +/// +/// FIX character field +/// +public class CharField : FieldBase { + public CharField(int tag) + : base(tag, '\0') { + } - public void setValue(char c) - { Obj = c; } + public CharField(int tag, char c) + : base(tag, c) { + } - protected override string makeString() - { - return Converters.CharConverter.Convert(Obj); - } + protected override string MakeString() { + return Converters.CharConverter.Convert(Value); } } diff --git a/QuickFIXn/Fields/DateTimeField.cs b/QuickFIXn/Fields/DateTimeField.cs index 2063c2eb8..15ae59b18 100644 --- a/QuickFIXn/Fields/DateTimeField.cs +++ b/QuickFIXn/Fields/DateTimeField.cs @@ -21,17 +21,9 @@ public DateTimeField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecisio timePrecision = timeFormatPrecision; } - - // quickfix compat - public DateTime getValue() - { return Obj; } - - public void setValue(DateTime dt) - { Obj = dt; } - - protected override string makeString() + protected override string MakeString() { - return Converters.DateTimeConverter.ToFIX(Obj, timePrecision); + return Converters.DateTimeConverter.ToFIX(Value, timePrecision); } } @@ -49,9 +41,9 @@ public DateOnlyField(int tag, DateTime dt, bool showMilliseconds) public DateOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision) : base(tag, dt, timeFormatPrecision) { } - protected override string makeString() + protected override string MakeString() { - return Converters.DateTimeConverter.ToFIXDateOnly(Obj); + return Converters.DateTimeConverter.ToFIXDateOnly(Value); } } @@ -69,9 +61,9 @@ public TimeOnlyField(int tag, DateTime dt, bool showMilliseconds) public TimeOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision) : base(tag, dt, timeFormatPrecision) { } - protected override string makeString() + protected override string MakeString() { - return Converters.DateTimeConverter.ToFIXTimeOnly(Obj, base.timePrecision); + return Converters.DateTimeConverter.ToFIXTimeOnly(Value, base.timePrecision); } } } diff --git a/QuickFIXn/Fields/DecimalField.cs b/QuickFIXn/Fields/DecimalField.cs index 4b86e04f6..574042239 100644 --- a/QuickFIXn/Fields/DecimalField.cs +++ b/QuickFIXn/Fields/DecimalField.cs @@ -15,16 +15,9 @@ public DecimalField(int tag) public DecimalField(int tag, Decimal val) : base(tag, val) { } - // quickfix compat - public Decimal getValue() - { return Obj; } - - public void setValue(Decimal d) - { Obj = d; } - - protected override string makeString() + protected override string MakeString() { - return Converters.DecimalConverter.Convert(Obj); + return Converters.DecimalConverter.Convert(Value); } } } diff --git a/QuickFIXn/Fields/FieldBase.cs b/QuickFIXn/Fields/FieldBase.cs index 761fa4f65..5796f26fa 100644 --- a/QuickFIXn/Fields/FieldBase.cs +++ b/QuickFIXn/Fields/FieldBase.cs @@ -1,104 +1,102 @@ -namespace QuickFix.Fields +using System; + +namespace QuickFix.Fields { /// /// Base class for all field types /// /// Internal storage type public abstract class FieldBase : IField + where T : notnull { + /// Set _stringVal (val only) and _stringField (tag=val) + + private T _value; + private int _tag; + private bool _changed; + private string _stringVal; // field value (not tag) formatted for fix + private string _stringField; // field string e.g. tag=val (no SOH) + /// /// Constructs a new field with the specified tag and value /// /// the FIX tag number - /// the value of the field - public FieldBase(int tag, T obj) + /// the value of the field + public FieldBase(int tag, T value) { _tag = tag; - _obj = obj; + _value = value; _changed = true; + + // We can't set these properly here because makeString() is abstract. + // See https://stackoverflow.com/a/119543/650475 + _stringVal = ""; + _stringField = ""; } - #region Properties - public T Obj + public T Value { - get { return _obj; } + get => _value; set { - _obj = value; + _value = value; _changed = true; } } + //----------------------------------- + // IField implementations + /// /// the FIX tag number /// - public override int Tag + public int Tag { - get { return _tag; } + get => _tag; set { _tag = value; _changed = true; } } - #endregion /// /// returns full fix string (e.g. "tag=val") /// - public override string toStringField() + public string ToStringField() { - if (_changed.Equals(true)) - makeStringFields(); + if (_changed) + MakeStringFields(); return _stringField; } /// - /// returns field value formatted for fix + /// returns field value (not tag) formatted for fix /// public override string ToString() { if (_changed) - makeStringFields(); + MakeStringFields(); return _stringVal; } /// - /// Value equality test - /// - /// - /// - public override bool Equals(object obj) - { - if (obj == null || GetType() != obj.GetType()) - return false; - - FieldBase f = (FieldBase)obj; - return this.Tag == f.Tag && this.Obj.Equals(f.Obj); - } - - public override int GetHashCode() - { - return Tag ^ Obj.GetHashCode(); - } - - /// - /// length of formatted field (including tag=val\001) + /// length of formatted field (including the trailing SOH) e.g. tag=val\001 /// - public override int getLength() + public int GetLength() { if (_changed) - makeStringFields(); + MakeStringFields(); return CharEncoding.DefaultEncoding.GetByteCount(_stringField) + 1; // +1 for SOH } /// - /// checksum + /// Sum of bytes; used in calculating checksum /// - public override int getTotal() + public int GetTotal() { if (_changed) - makeStringFields(); + MakeStringFields(); int sum = 0; byte[] array = CharEncoding.DefaultEncoding.GetBytes(_stringField); @@ -106,27 +104,66 @@ public override int getTotal() { sum += b; } - return (sum + 1); // +1 for SOH + return sum + 1; // +1 for SOH + } + + //----------------------------------- + // C# Equals/HashCode overrides + + /// + /// Value equality test + /// + /// + /// + public override bool Equals(object? obj) + { + if (obj is null || GetType() != obj.GetType()) + return false; + + FieldBase f = (FieldBase)obj; + return this.Tag == f.Tag && this.Value.Equals(f.Value); + } + + public override int GetHashCode() + { + return Tag ^ Value.GetHashCode(); } - protected abstract string makeString(); + /// + /// Convert underlying field value to fix-ready string + /// + /// + protected abstract string MakeString(); /// - /// returns tag=val + /// Set _stringVal (val only) and _stringField (tag=val) /// - private void makeStringFields() + private void MakeStringFields() { - _stringVal = makeString(); + _stringVal = MakeString(); _stringField = Tag + "=" + _stringVal; _changed = false; } - #region Private members - private string _stringField; - private bool _changed; - private T _obj; - private int _tag; - private string _stringVal; - #endregion + [Obsolete("Use capitalized ToStringField() instead")] + public string toStringField() { return ToStringField(); } + [Obsolete("Use capitalized GetLength() instead")] + public int getLength() { return GetLength(); } + [Obsolete("Use capitalized GetTotal() instead")] + public int getTotal() { return GetTotal(); } + [Obsolete("Renamed to 'Value'")] + public T Obj + { + get => _value; + set + { + _value = value; + _changed = true; + } + } + [Obsolete("Use Value getter property")] + public T getValue() { return Value; } + [Obsolete("Use Value setter property")] + public void setValue(T v) { Value = v; } } -} \ No newline at end of file +} diff --git a/QuickFIXn/Fields/IField.cs b/QuickFIXn/Fields/IField.cs index b8eb97d17..ff39b4473 100644 --- a/QuickFIXn/Fields/IField.cs +++ b/QuickFIXn/Fields/IField.cs @@ -1,33 +1,40 @@ #nullable enable +using System; + namespace QuickFix.Fields { /// /// Interface for all field classes /// - public abstract class IField + public interface IField { - #region Properties - public abstract int Tag { get; set; } - #endregion + public int Tag { get; set; } /// /// returns full fix string: tag=val /// - public abstract string toStringField(); + public string ToStringField(); /// - /// returns formatted string for fix + /// returns field value (not tag) formatted for FIX /// - public abstract override string ToString(); + public string ToString(); /// - /// length of formatted field (including tag=val\001) + /// length of formatted field (including the trailing SOH) e.g. tag=val\001 /// - public abstract int getLength(); + public int GetLength(); /// - /// checksum + /// Sum of bytes; used in calculating checksum /// - public abstract int getTotal(); + public int GetTotal(); + + [Obsolete("Use capitalized ToStringField() instead")] + public string toStringField(); + [Obsolete("Use capitalized GetLength() instead")] + public int getLength(); + [Obsolete("Use capitalized GetTotal() instead")] + public int getTotal(); } } diff --git a/QuickFIXn/Fields/IntField.cs b/QuickFIXn/Fields/IntField.cs index 7afce9f59..fc1cd850d 100644 --- a/QuickFIXn/Fields/IntField.cs +++ b/QuickFIXn/Fields/IntField.cs @@ -1,30 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Text; +namespace QuickFix.Fields; -namespace QuickFix.Fields -{ - /// - /// An integer message field - /// - public class IntField : FieldBase - { - public IntField(int tag) - : base(tag, 0) { } - - public IntField(int tag, int val) - : base(tag, val) {} - - // quickfix compat - public int getValue() - { return Obj; } +/// +/// FIX Integer field +/// +public class IntField : FieldBase { + public IntField(int tag) + : base(tag, 0) { + } - public void setValue(int v) - { Obj = v; } + public IntField(int tag, int val) + : base(tag, val) { + } - protected override string makeString() - { - return Converters.IntConverter.Convert(Obj); - } + protected override string MakeString() { + return Converters.IntConverter.Convert(Value); } } diff --git a/QuickFIXn/Fields/StringField.cs b/QuickFIXn/Fields/StringField.cs index 9120e094b..7e73025c5 100644 --- a/QuickFIXn/Fields/StringField.cs +++ b/QuickFIXn/Fields/StringField.cs @@ -15,16 +15,9 @@ public StringField(int tag) public StringField(int tag, string str) : base(tag, str) { } - // quickfix compat - public string getValue() - { return Obj; } - - public void setValue(string val) - { Obj = val; } - - protected override string makeString() + protected override string MakeString() { - return Obj; + return Value; } } } diff --git a/QuickFIXn/Fields/ULongField.cs b/QuickFIXn/Fields/ULongField.cs index 6a30c7ad7..20b045079 100644 --- a/QuickFIXn/Fields/ULongField.cs +++ b/QuickFIXn/Fields/ULongField.cs @@ -15,16 +15,9 @@ public ULongField(int tag) public ULongField(int tag, ulong val) : base(tag, val) {} - // quickfix compat - public ulong getValue() - { return Obj; } - - public void setValue(ulong v) - { Obj = v; } - - protected override string makeString() + protected override string MakeString() { - return Converters.ULongConverter.Convert(Obj); + return Converters.ULongConverter.Convert(Value); } } } diff --git a/QuickFIXn/Message/FieldMap.cs b/QuickFIXn/Message/FieldMap.cs index 12cc75cc9..7a23807da 100644 --- a/QuickFIXn/Message/FieldMap.cs +++ b/QuickFIXn/Message/FieldMap.cs @@ -120,7 +120,7 @@ public bool SetField(IField field, bool overwrite) /// public BooleanField GetField(BooleanField field) { - field.Obj = GetBoolean(field.Tag); + field.Value = GetBoolean(field.Tag); return field; } @@ -132,7 +132,7 @@ public BooleanField GetField(BooleanField field) /// public StringField GetField(StringField field) { - field.Obj = GetString(field.Tag); + field.Value = GetString(field.Tag); return field; } @@ -144,7 +144,7 @@ public StringField GetField(StringField field) /// public CharField GetField(CharField field) { - field.Obj = GetChar(field.Tag); + field.Value = GetChar(field.Tag); return field; } @@ -156,7 +156,7 @@ public CharField GetField(CharField field) /// public IntField GetField(IntField field) { - field.Obj = GetInt(field.Tag); + field.Value = GetInt(field.Tag); return field; } @@ -168,7 +168,7 @@ public IntField GetField(IntField field) /// public ULongField GetField(ULongField field) { - field.Obj = GetULong(field.Tag); + field.Value = GetULong(field.Tag); return field; } @@ -180,7 +180,7 @@ public ULongField GetField(ULongField field) /// public DecimalField GetField(DecimalField field) { - field.Obj = GetDecimal(field.Tag); + field.Value = GetDecimal(field.Tag); return field; } @@ -192,7 +192,7 @@ public DecimalField GetField(DecimalField field) /// public DateTimeField GetField(DateTimeField field) { - field.Obj = GetDateTime(field.Tag); + field.Value = GetDateTime(field.Tag); return field; } @@ -204,7 +204,7 @@ public DateTimeField GetField(DateTimeField field) /// public DateOnlyField GetField(DateOnlyField field) { - field.Obj = GetDateOnly(field.Tag); + field.Value = GetDateOnly(field.Tag); return field; } @@ -216,7 +216,7 @@ public DateOnlyField GetField(DateOnlyField field) /// public TimeOnlyField GetField(TimeOnlyField field) { - field.Obj = GetTimeOnly(field.Tag); + field.Value = GetTimeOnly(field.Tag); return field; } @@ -318,7 +318,7 @@ public int GetInt(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase intField) - return intField.Obj; + return intField.Value; return IntConverter.Convert(fld.ToString()); } @@ -335,7 +335,7 @@ public ulong GetULong(int tag) { IField fld = _fields[tag]; if (fld.GetType() == typeof(ULongField)) - return ((ULongField)fld).Obj; + return ((ULongField)fld).Value; return ULongConverter.Convert(fld.ToString()); } catch (System.Collections.Generic.KeyNotFoundException) @@ -357,9 +357,9 @@ public DateTime GetDateTime(int tag) return fld switch { - DateOnlyField dateOnlyField => dateOnlyField.Obj.Date, - TimeOnlyField timeOnlyField => new DateTime(1980, 01, 01).Add(timeOnlyField.Obj.TimeOfDay), - FieldBase dateTimeField => dateTimeField.Obj, + DateOnlyField dateOnlyField => dateOnlyField.Value.Date, + TimeOnlyField timeOnlyField => new DateTime(1980, 01, 01).Add(timeOnlyField.Value.TimeOfDay), + FieldBase dateTimeField => dateTimeField.Value, _ => DateTimeConverter.ParseToDateTime(fld.ToString()) }; } @@ -376,7 +376,7 @@ public DateTime GetDateOnly(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase dateTimeField) - return dateTimeField.Obj.Date; + return dateTimeField.Value.Date; return DateTimeConverter.ParseToDateOnly(fld.ToString()); } @@ -393,7 +393,7 @@ public DateTime GetTimeOnly(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase dateTimeField) - return new DateTime(1980, 01, 01).Add(dateTimeField.Obj.TimeOfDay); + return new DateTime(1980, 01, 01).Add(dateTimeField.Value.TimeOfDay); return DateTimeConverter.ParseToTimeOnly(fld.ToString()); } @@ -410,7 +410,7 @@ public bool GetBoolean(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase boolField) - return boolField.Obj; + return boolField.Value; return BoolConverter.Convert(fld.ToString()); } @@ -441,7 +441,7 @@ public char GetChar(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase charField) - return charField.Obj; + return charField.Value; return CharConverter.Convert(fld.ToString()); } @@ -458,7 +458,7 @@ public decimal GetDecimal(int tag) throw new FieldNotFoundException(tag); if (fld is FieldBase decimalField) - return decimalField.Obj; + return decimalField.Value; return DecimalConverter.Convert(fld.ToString()); } @@ -528,13 +528,13 @@ public int CalculateTotal() foreach (IField field in _fields.Values) { if (field.Tag != Fields.Tags.CheckSum) - total += field.getTotal(); + total += field.GetTotal(); } foreach (IField field in this.RepeatedTags) { if (field.Tag != Fields.Tags.CheckSum) - total += field.getTotal(); + total += field.GetTotal(); } foreach (List groupList in _groups.Values) @@ -550,23 +550,21 @@ public int CalculateLength() int total = 0; foreach (IField field in _fields.Values) { - if (field != null - && field.Tag != Tags.BeginString + if (field.Tag != Tags.BeginString && field.Tag != Tags.BodyLength && field.Tag != Tags.CheckSum) { - total += field.getLength(); + total += field.GetLength(); } } foreach (IField field in this.RepeatedTags) { - if (field != null - && field.Tag != Tags.BeginString + if (field.Tag != Tags.BeginString && field.Tag != Tags.BodyLength && field.Tag != Tags.CheckSum) { - total += field.getLength(); + total += field.GetLength(); } } @@ -596,7 +594,7 @@ public virtual string CalculateString() /// public virtual string CalculateString(StringBuilder sb, int[] preFields) { - HashSet groupCounterTags = new HashSet(_groups.Keys); + HashSet groupCounterTags = new(_groups.Keys); foreach (int preField in preFields) { @@ -618,7 +616,7 @@ public virtual string CalculateString(StringBuilder sb, int[] preFields) continue; if (preFields.Contains(field.Tag)) continue; //already did this one - sb.Append(field.Tag.ToString() + "=" + field.ToString()); + sb.Append($"{field.Tag}={field.ToString()}"); sb.Append(Message.SOH); } @@ -631,7 +629,7 @@ public virtual string CalculateString(StringBuilder sb, int[] preFields) if (groupList.Count == 0) continue; //probably unnecessary, but it doesn't hurt to check - sb.Append(_fields[counterTag].toStringField()); + sb.Append(_fields[counterTag].ToStringField()); sb.Append(Message.SOH); foreach (Group group in groupList) @@ -647,7 +645,7 @@ public virtual string CalculateString(StringBuilder sb, int[] preFields) /// the counter tag of the group /// public int GroupCount(int fieldNo) { - return _groups.ContainsKey(fieldNo) ? _groups[fieldNo].Count : 0; + return _groups.TryGetValue(fieldNo, out var group) ? group.Count : 0; } /// diff --git a/QuickFIXn/Message/Message.cs b/QuickFIXn/Message/Message.cs index c5cce14ba..f978f0b11 100644 --- a/QuickFIXn/Message/Message.cs +++ b/QuickFIXn/Message/Message.cs @@ -146,7 +146,7 @@ public static StringField ExtractField(string msgstr, ref int pos) public static string ExtractBeginString(string msgstr) { int i = 0; - return ExtractField(msgstr, ref i).Obj; + return ExtractField(msgstr, ref i).Value; } public static bool IsHeaderField(int tag) @@ -375,7 +375,7 @@ public void FromString( if (Tags.MsgType.Equals(f.Tag)) { - string msgType = f.Obj; + string msgType = f.Value; if (appDict is not null) { msgMap = appDict.GetMapForMessage(msgType); @@ -655,48 +655,48 @@ public void ReverseRoute(Header header) { SenderCompID senderCompId = new SenderCompID(); header.GetField(senderCompId); - if (senderCompId.Obj.Length > 0) - Header.SetField(new TargetCompID(senderCompId.Obj)); + if (senderCompId.Value.Length > 0) + Header.SetField(new TargetCompID(senderCompId.Value)); } if (header.IsSetField(Tags.SenderSubID)) { SenderSubID senderSubId = new SenderSubID(); header.GetField(senderSubId); - if (senderSubId.Obj.Length > 0) - Header.SetField(new TargetSubID(senderSubId.Obj)); + if (senderSubId.Value.Length > 0) + Header.SetField(new TargetSubID(senderSubId.Value)); } if (header.IsSetField(Tags.SenderLocationID)) { SenderLocationID senderLocationId = new SenderLocationID(); header.GetField(senderLocationId); - if (senderLocationId.Obj.Length > 0) - Header.SetField(new TargetLocationID(senderLocationId.Obj)); + if (senderLocationId.Value.Length > 0) + Header.SetField(new TargetLocationID(senderLocationId.Value)); } if (header.IsSetField(Tags.TargetCompID)) { TargetCompID targetCompId = new TargetCompID(); header.GetField(targetCompId); - if (targetCompId.Obj.Length > 0) - Header.SetField(new SenderCompID(targetCompId.Obj)); + if (targetCompId.Value.Length > 0) + Header.SetField(new SenderCompID(targetCompId.Value)); } if (header.IsSetField(Tags.TargetSubID)) { TargetSubID targetSubId = new TargetSubID(); header.GetField(targetSubId); - if (targetSubId.Obj.Length > 0) - Header.SetField(new SenderSubID(targetSubId.Obj)); + if (targetSubId.Value.Length > 0) + Header.SetField(new SenderSubID(targetSubId.Value)); } if (header.IsSetField(Tags.TargetLocationID)) { TargetLocationID targetLocationId = new TargetLocationID(); header.GetField(targetLocationId); - if (targetLocationId.Obj.Length > 0) - Header.SetField(new SenderLocationID(targetLocationId.Obj)); + if (targetLocationId.Value.Length > 0) + Header.SetField(new SenderLocationID(targetLocationId.Value)); } // optional routing tags diff --git a/QuickFIXn/MessageBuilder.cs b/QuickFIXn/MessageBuilder.cs index c7253522f..49eb3fbbe 100644 --- a/QuickFIXn/MessageBuilder.cs +++ b/QuickFIXn/MessageBuilder.cs @@ -41,7 +41,7 @@ internal MessageBuilder( internal Message Build() { - Message message = _msgFactory.Create(BeginString, _defaultApplVerId, MsgType.Obj); + Message message = _msgFactory.Create(BeginString, _defaultApplVerId, MsgType.Value); message.FromString( _msgStr, _validateLengthAndChecksum, @@ -58,7 +58,7 @@ internal Message RejectableMessage() if (_message is not null) return _message; - Message message = _msgFactory.Create(BeginString, MsgType.Obj); + Message message = _msgFactory.Create(BeginString, MsgType.Value); message.FromString( _msgStr, false, diff --git a/QuickFIXn/Session.cs b/QuickFIXn/Session.cs index 8612fc8c6..3fd0c4ff2 100755 --- a/QuickFIXn/Session.cs +++ b/QuickFIXn/Session.cs @@ -550,7 +550,7 @@ internal void Next(MessageBuilder msgBuilder) if (_appDoesEarlyIntercept) ((IApplicationExt)Application).FromEarlyIntercept(message, SessionID); - string msgType = msgBuilder.MsgType.Obj; + string msgType = msgBuilder.MsgType.Value; string beginString = msgBuilder.BeginString; if (!beginString.Equals(SessionID.BeginString)) @@ -600,7 +600,7 @@ internal void Next(MessageBuilder msgBuilder) try { - if (MsgType.LOGON.Equals(msgBuilder.MsgType.Obj)) + if (MsgType.LOGON.Equals(msgBuilder.MsgType.Value)) Disconnect("Logon message is not valid"); } catch (MessageParseError) @@ -616,7 +616,7 @@ internal void Next(MessageBuilder msgBuilder) } catch (UnsupportedVersion uvx) { - if (MsgType.LOGOUT.Equals(msgBuilder.MsgType.Obj)) + if (MsgType.LOGOUT.Equals(msgBuilder.MsgType.Value)) { NextLogout(message!); } @@ -641,7 +641,7 @@ internal void Next(MessageBuilder msgBuilder) } else { - if (MsgType.LOGON.Equals(msgBuilder.MsgType.Obj)) + if (MsgType.LOGON.Equals(msgBuilder.MsgType.Value)) { Log.OnEvent("Required field missing from logon"); Disconnect("Required field missing from logon"); @@ -1547,12 +1547,12 @@ protected bool SendRaw(Message message, SeqNumType seqNum) Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false); if (message.IsSetField(resetSeqNumFlag)) message.GetField(resetSeqNumFlag); - if (resetSeqNumFlag.getValue()) + if (resetSeqNumFlag.Value) { _state.Reset("ResetSeqNumFlag"); message.Header.SetField(new Fields.MsgSeqNum(_state.NextSenderMsgSeqNum)); } - _state.SentReset = resetSeqNumFlag.Obj; + _state.SentReset = resetSeqNumFlag.Value; } } else diff --git a/QuickFIXn/SessionFactory.cs b/QuickFIXn/SessionFactory.cs index 0323a5d7a..c6650796b 100755 --- a/QuickFIXn/SessionFactory.cs +++ b/QuickFIXn/SessionFactory.cs @@ -98,7 +98,7 @@ public Session Create(SessionID sessionId, SettingsDictionary settings) } string senderDefaultApplVerId = ""; if(defaultApplVerId is not null) - senderDefaultApplVerId = defaultApplVerId.Obj; + senderDefaultApplVerId = defaultApplVerId.Value; Session session = new Session( isInitiator, @@ -204,7 +204,7 @@ protected void ProcessFixTDataDictionaries(SessionID sessionId, SettingsDictiona { Fields.ApplVerID applVerId = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID)); DataDictionary.DataDictionary dd = CreateDataDictionary(sessionId, settings, SessionSettings.APP_DATA_DICTIONARY, sessionId.BeginString); - provider.AddApplicationDataDictionary(applVerId.Obj, dd); + provider.AddApplicationDataDictionary(applVerId.Value, dd); } else { @@ -215,7 +215,7 @@ protected void ProcessFixTDataDictionaries(SessionID sessionId, SettingsDictiona string beginStringQualifier = setting.Key.Substring(offset); DataDictionary.DataDictionary dd = CreateDataDictionary(sessionId, settings, setting.Key, beginStringQualifier); - provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Obj, dd); + provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Value, dd); } } } diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index aa8a7c97b..e98e31203 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -35,6 +35,10 @@ What's New finishes loading all the dlls (gbirchmeier, with thanks to diagnosis by Brian Leach aka baffled) (Note: this may be the cause of spurious "incorrect BeginString" issues that have been observed) * #877 - throw an exception if Message.ToJSON(dd=null,convertEnumsToDescriptions=true) is called (gbirchmeier) +* #TBD - cleanup/nullable-ize IField-derived classes (gbirchmeier) + * deprecate lower-case-starting function names (renamed to upper-case-starting) + * deprecate Field.Obj (renamed to Value) + * deprecate Field.getValue/setValue (just use Value getter/setter) ### v1.12.0 diff --git a/UnitTests/DataDictionaryTests.cs b/UnitTests/DataDictionaryTests.cs index fdb261884..aac8303d1 100644 --- a/UnitTests/DataDictionaryTests.cs +++ b/UnitTests/DataDictionaryTests.cs @@ -315,7 +315,7 @@ public void CheckGroupCountTest() //verify that FromString didn't correct the counter //HEY YOU, READ THIS NOW: if these fail, first check if MessageTests::FromString_DoNotCorrectCounter() passes - Assert.AreEqual("386=3", n.NoTradingSessions.toStringField()); + Assert.AreEqual("386=3", n.NoTradingSessions.ToStringField()); StringAssert.Contains("386=3", n.ConstructString()); Assert.Throws(delegate { dd.CheckGroupCount(n.NoTradingSessions, n, "D"); }); diff --git a/UnitTests/DataDictionary_ValidateTests.cs b/UnitTests/DataDictionary_ValidateTests.cs index 809399ff2..af32fa3c9 100644 --- a/UnitTests/DataDictionary_ValidateTests.cs +++ b/UnitTests/DataDictionary_ValidateTests.cs @@ -81,10 +81,10 @@ public void ValidateWithRepeatingGroupTest() MsgType msgType = Message.IdentifyType(msgStr); string beginString = Message.ExtractBeginString(msgStr); - Message message = f.Create(beginString, msgType.Obj); + Message message = f.Create(beginString, msgType.Value); message.FromString(msgStr, true, dd, dd, f); - DataDictionary.Validate(message, dd, dd, beginString, msgType.Obj); + DataDictionary.Validate(message, dd, dd, beginString, msgType.Value); } [Test] diff --git a/UnitTests/FieldMapTests.cs b/UnitTests/FieldMapTests.cs index 25ba7ea4f..f5ad464b2 100644 --- a/UnitTests/FieldMapTests.cs +++ b/UnitTests/FieldMapTests.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using NUnit.Framework; using QuickFix; using QuickFix.Fields; @@ -12,10 +9,10 @@ namespace UnitTests [TestFixture] public class FieldMapTests { - private FieldMap fieldmap; + private FieldMap _fieldmap; public FieldMapTests() { - this.fieldmap = new FieldMap(); + this._fieldmap = new FieldMap(); } [Test] @@ -23,14 +20,14 @@ public void CharFieldTest() { CharField field = new CharField(100, 'd'); - fieldmap.SetField(field); + _fieldmap.SetField(field); CharField refield = new CharField(100); - fieldmap.GetField(refield); - Assert.That('d', Is.EqualTo(refield.Obj)); - field.Obj = 'e'; - fieldmap.SetField(field); - CharField r = fieldmap.GetField(refield); - Assert.That('e', Is.EqualTo(refield.Obj)); + _fieldmap.GetField(refield); + Assert.That('d', Is.EqualTo(refield.Value)); + field.Value = 'e'; + _fieldmap.SetField(field); + CharField r = _fieldmap.GetField(refield); + Assert.That('e', Is.EqualTo(refield.Value)); Assert.AreSame(refield, r); } @@ -39,38 +36,38 @@ public void CharFieldTest() [Test] public void GetCharTest() { - fieldmap.SetField(new CharField(20, 'a')); - Assert.That(fieldmap.GetChar(20), Is.EqualTo('a')); - fieldmap.SetField(new StringField(21, "b")); - Assert.That(fieldmap.GetChar(21), Is.EqualTo('b')); + _fieldmap.SetField(new CharField(20, 'a')); + Assert.That(_fieldmap.GetChar(20), Is.EqualTo('a')); + _fieldmap.SetField(new StringField(21, "b")); + Assert.That(_fieldmap.GetChar(21), Is.EqualTo('b')); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetString(99900); }); + delegate { _fieldmap.GetString(99900); }); } [Test] public void GetDecimalTest() { var val = new Decimal(20.4); - fieldmap.SetField(new DecimalField(200, val)); - Assert.That(fieldmap.GetDecimal(200), Is.EqualTo(val)); - fieldmap.SetField(new StringField(201, "33.22")); - Assert.That(fieldmap.GetDecimal(201), Is.EqualTo(new Decimal(33.22))); + _fieldmap.SetField(new DecimalField(200, val)); + Assert.That(_fieldmap.GetDecimal(200), Is.EqualTo(val)); + _fieldmap.SetField(new StringField(201, "33.22")); + Assert.That(_fieldmap.GetDecimal(201), Is.EqualTo(new Decimal(33.22))); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetString(99900); }); + delegate { _fieldmap.GetString(99900); }); } - + [Test] public void StringFieldTest() { - fieldmap.SetField(new Account("hello")); + _fieldmap.SetField(new Account("hello")); Account acct = new Account(); - fieldmap.GetField(acct); - Assert.That("hello", Is.EqualTo(acct.Obj)); - fieldmap.SetField(new Account("helloworld")); - StringField r = fieldmap.GetField(acct); - Assert.That("helloworld", Is.EqualTo(acct.getValue())); + _fieldmap.GetField(acct); + Assert.That("hello", Is.EqualTo(acct.Value)); + _fieldmap.SetField(new Account("helloworld")); + StringField r = _fieldmap.GetField(acct); + Assert.That("helloworld", Is.EqualTo(acct.Value)); Assert.AreSame(r, acct); } @@ -78,23 +75,23 @@ public void StringFieldTest() [Test] public void GetStringTest() { - fieldmap.SetField(new Account("hello")); - Assert.That(fieldmap.GetString(QuickFix.Fields.Tags.Account), Is.EqualTo("hello")); + _fieldmap.SetField(new Account("hello")); + Assert.That(_fieldmap.GetString(QuickFix.Fields.Tags.Account), Is.EqualTo("hello")); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetString(99900); }); + delegate { _fieldmap.GetString(99900); }); } [Test] public void DateTimeFieldTest() { - fieldmap.SetField(new DateTimeField(Tags.TransactTime, new DateTime(2009, 12, 10))); + _fieldmap.SetField(new DateTimeField(Tags.TransactTime, new DateTime(2009, 12, 10))); TransactTime tt = new TransactTime(); - fieldmap.GetField(tt); - Assert.That(new DateTime(2009, 12, 10), Is.EqualTo(tt.Obj)); - fieldmap.SetField(new TransactTime(new DateTime(2010, 12, 10))); - DateTimeField r = fieldmap.GetField(tt); - Assert.That(new DateTime(2010, 12, 10), Is.EqualTo(tt.getValue())); + _fieldmap.GetField(tt); + Assert.That(new DateTime(2009, 12, 10), Is.EqualTo(tt.Value)); + _fieldmap.SetField(new TransactTime(new DateTime(2010, 12, 10))); + DateTimeField r = _fieldmap.GetField(tt); + Assert.That(new DateTime(2010, 12, 10), Is.EqualTo(tt.Value)); Assert.AreSame(r, tt); } @@ -102,39 +99,39 @@ public void DateTimeFieldTest() [Test] public void DateTimeFieldNanoTest() { - fieldmap.SetField(new StringField(Tags.TransactTime, "20200309-20:53:10.643649215")); + _fieldmap.SetField(new StringField(Tags.TransactTime, "20200309-20:53:10.643649215")); TransactTime tt = new TransactTime(); - fieldmap.GetField(tt); + _fieldmap.GetField(tt); // Ticks resolution is 100 nanoseconds, so we lose the last 2 decimal points - Assert.That(tt.Obj.Ticks, Is.EqualTo(637193839906436492)); + Assert.That(tt.Value.Ticks, Is.EqualTo(637193839906436492)); } [Test] public void DateOnlyFieldTest() { - fieldmap.SetField(new DateOnlyField(Tags.MDEntryDate, new DateTime(2009, 12, 10, 1, 2, 3))); + _fieldmap.SetField(new DateOnlyField(Tags.MDEntryDate, new DateTime(2009, 12, 10, 1, 2, 3))); MDEntryDate ed = new MDEntryDate(); - fieldmap.GetField(ed); - Assert.AreEqual(new DateTime(2009, 12, 10), ed.Obj); - fieldmap.SetField(new MDEntryDate(new DateTime(2010, 12, 10))); - DateOnlyField r = fieldmap.GetField(ed); - Assert.AreEqual(new DateTime(2010, 12, 10), ed.getValue()); - + _fieldmap.GetField(ed); + Assert.AreEqual(new DateTime(2009, 12, 10), ed.Value); + _fieldmap.SetField(new MDEntryDate(new DateTime(2010, 12, 10))); + DateOnlyField r = _fieldmap.GetField(ed); + Assert.AreEqual(new DateTime(2010, 12, 10), ed.Value); + Assert.AreSame(r, ed); Assert.AreEqual("20101210", ed.ToString()); } [Test] public void TimeOnlyFieldTest() - { - fieldmap.SetField(new TimeOnlyField(Tags.MDEntryTime, new DateTime(1, 1, 1, 1, 2, 3), false)); + { + _fieldmap.SetField(new TimeOnlyField(Tags.MDEntryTime, new DateTime(1, 1, 1, 1, 2, 3), false)); MDEntryTime et = new MDEntryTime(); - fieldmap.GetField(et); - Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 3), et.Obj); - fieldmap.SetField(new MDEntryTime(new DateTime(1, 1, 1, 1, 2, 5))); - TimeOnlyField r = fieldmap.GetField(et); - Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 5), et.getValue()); - + _fieldmap.GetField(et); + Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 3), et.Value); + _fieldmap.SetField(new MDEntryTime(new DateTime(1, 1, 1, 1, 2, 5))); + TimeOnlyField r = _fieldmap.GetField(et); + Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 5), et.Value); + Assert.AreSame(r, et); Assert.AreEqual("01:02:05.000", et.ToString()); } @@ -142,30 +139,30 @@ public void TimeOnlyFieldTest() [Test] public void GetDateTimeTest() { - fieldmap.SetField(new DateTimeField(Tags.TransactTime, new DateTime(2009, 12, 10))); - Assert.That(fieldmap.GetDateTime(Tags.TransactTime), Is.EqualTo(new DateTime(2009, 12, 10))); - fieldmap.SetField(new StringField(233, "20091211-12:12:44")); - Assert.That(fieldmap.GetDateTime(233), Is.EqualTo(new DateTime(2009, 12, 11, 12, 12, 44))); + _fieldmap.SetField(new DateTimeField(Tags.TransactTime, new DateTime(2009, 12, 10))); + Assert.That(_fieldmap.GetDateTime(Tags.TransactTime), Is.EqualTo(new DateTime(2009, 12, 10))); + _fieldmap.SetField(new StringField(233, "20091211-12:12:44")); + Assert.That(_fieldmap.GetDateTime(233), Is.EqualTo(new DateTime(2009, 12, 11, 12, 12, 44))); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetDateTime(99900); }); + delegate { _fieldmap.GetDateTime(99900); }); } [Test] public void GetDateOnlyTest() { - fieldmap.SetField(new DateOnlyField(Tags.MDEntryDate, new DateTime(2009, 12, 10, 1, 2, 3))); - Assert.AreEqual(new DateTime(2009, 12, 10), fieldmap.GetDateTime(Tags.MDEntryDate)); - fieldmap.SetField(new StringField(233, "20091211")); - Assert.AreEqual(new DateTime(2009, 12, 11), fieldmap.GetDateOnly(233)); + _fieldmap.SetField(new DateOnlyField(Tags.MDEntryDate, new DateTime(2009, 12, 10, 1, 2, 3))); + Assert.AreEqual(new DateTime(2009, 12, 10), _fieldmap.GetDateTime(Tags.MDEntryDate)); + _fieldmap.SetField(new StringField(233, "20091211")); + Assert.AreEqual(new DateTime(2009, 12, 11), _fieldmap.GetDateOnly(233)); } [Test] public void GetTimeOnlyTest() { - fieldmap.SetField(new TimeOnlyField(Tags.MDEntryTime, new DateTime(2009, 12, 10, 1, 2, 3))); - Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 3), fieldmap.GetDateTime(Tags.MDEntryTime)); - fieldmap.SetField(new StringField(233, "07:30:47")); - Assert.AreEqual(new DateTime(1980, 01, 01, 7, 30, 47), fieldmap.GetTimeOnly(233)); + _fieldmap.SetField(new TimeOnlyField(Tags.MDEntryTime, new DateTime(2009, 12, 10, 1, 2, 3))); + Assert.AreEqual(new DateTime(1980, 01, 01, 1, 2, 3), _fieldmap.GetDateTime(Tags.MDEntryTime)); + _fieldmap.SetField(new StringField(233, "07:30:47")); + Assert.AreEqual(new DateTime(1980, 01, 01, 7, 30, 47), _fieldmap.GetTimeOnly(233)); } [Test] @@ -173,13 +170,13 @@ public void BooleanFieldTest() { BooleanField field = new BooleanField(200, true); BooleanField refield = new BooleanField(200); - fieldmap.SetField(field); - fieldmap.GetField(refield); - Assert.That(true, Is.EqualTo(refield.Obj)); - field.setValue(false); - fieldmap.SetField(field); - BooleanField r = fieldmap.GetField(refield); - Assert.That(false, Is.EqualTo(refield.Obj)); + _fieldmap.SetField(field); + _fieldmap.GetField(refield); + Assert.That(true, Is.EqualTo(refield.Value)); + field.Value = false; + _fieldmap.SetField(field); + BooleanField r = _fieldmap.GetField(refield); + Assert.That(false, Is.EqualTo(refield.Value)); Assert.AreSame(r, refield); } @@ -187,12 +184,12 @@ public void BooleanFieldTest() [Test] public void GetBooleanTest() { - fieldmap.SetField(new BooleanField(200, true)); - Assert.That(fieldmap.GetBoolean(200), Is.EqualTo(true)); - fieldmap.SetField(new StringField(201, "N")); - Assert.That(fieldmap.GetBoolean(201), Is.EqualTo(false)); + _fieldmap.SetField(new BooleanField(200, true)); + Assert.That(_fieldmap.GetBoolean(200), Is.EqualTo(true)); + _fieldmap.SetField(new StringField(201, "N")); + Assert.That(_fieldmap.GetBoolean(201), Is.EqualTo(false)); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetString(99900); }); + delegate { _fieldmap.GetString(99900); }); } [Test] @@ -201,13 +198,13 @@ public void IntFieldTest() IntField field = new IntField(200, 101); IntField refield = new IntField(200); - fieldmap.SetField(field); - fieldmap.GetField(refield); - Assert.That(101, Is.EqualTo(refield.Obj)); - field.setValue(102); - fieldmap.SetField(field); - IntField r = fieldmap.GetField(refield); - Assert.That(102, Is.EqualTo(refield.Obj)); + _fieldmap.SetField(field); + _fieldmap.GetField(refield); + Assert.That(101, Is.EqualTo(refield.Value)); + field.Value = 102; + _fieldmap.SetField(field); + IntField r = _fieldmap.GetField(refield); + Assert.That(102, Is.EqualTo(refield.Value)); Assert.AreSame(r, refield); } @@ -217,12 +214,12 @@ public void GetIntTest() { IntField field = new IntField(200, 101); - fieldmap.SetField(field); - Assert.That(fieldmap.GetInt(200), Is.EqualTo(101)); - fieldmap.SetField(new StringField(202, "2222")); - Assert.That(fieldmap.GetInt(202), Is.EqualTo(2222)); + _fieldmap.SetField(field); + Assert.That(_fieldmap.GetInt(200), Is.EqualTo(101)); + _fieldmap.SetField(new StringField(202, "2222")); + Assert.That(_fieldmap.GetInt(202), Is.EqualTo(2222)); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetInt(99900); }); + delegate { _fieldmap.GetInt(99900); }); } [Test] @@ -230,13 +227,13 @@ public void DecimalFieldTest() { DecimalField field = new DecimalField(200, new Decimal(101.0001)); DecimalField refield = new DecimalField(200); - fieldmap.SetField(field); - fieldmap.GetField(refield); - Assert.That(101.0001, Is.EqualTo(refield.Obj)); - field.setValue(new Decimal(101.0002)); - fieldmap.SetField(field); - DecimalField r = fieldmap.GetField(refield); - Assert.That(101.0002, Is.EqualTo(refield.Obj)); + _fieldmap.SetField(field); + _fieldmap.GetField(refield); + Assert.That(101.0001, Is.EqualTo(refield.Value)); + field.Value = 101.0002m; + _fieldmap.SetField(field); + DecimalField r = _fieldmap.GetField(refield); + Assert.That(101.0002, Is.EqualTo(refield.Value)); Assert.AreSame(r, refield); } @@ -245,8 +242,8 @@ public void DecimalFieldTest() public void DefaultFieldTest() { DecimalField field = new DecimalField(200, new Decimal(101.0001)); - fieldmap.SetField(field); - string refield = fieldmap.GetString(200); + _fieldmap.SetField(field); + string refield = _fieldmap.GetString(200); Assert.That("101.0001", Is.EqualTo(refield)); } @@ -255,37 +252,37 @@ public void SetFieldOverwriteTest() { IntField field = new IntField(21901, 1011); IntField refield = new IntField(21901); - fieldmap.SetField(field, false); - fieldmap.GetField(refield); - Assert.That(1011, Is.EqualTo(refield.Obj)); - field.setValue(1021); + _fieldmap.SetField(field, false); + _fieldmap.GetField(refield); + Assert.That(1011, Is.EqualTo(refield.Value)); + field.Value = 1021; IntField refield2 = new IntField(21901); - fieldmap.SetField(field, false); - fieldmap.GetField(refield2); - Assert.That(refield.Obj, Is.EqualTo(1011)); - fieldmap.SetField(field, true); + _fieldmap.SetField(field, false); + _fieldmap.GetField(refield2); + Assert.That(refield.Value, Is.EqualTo(1011)); + _fieldmap.SetField(field, true); IntField refield3 = new IntField(21901); - fieldmap.GetField(refield3); - Assert.That(1021, Is.EqualTo(refield3.Obj)); + _fieldmap.GetField(refield3); + Assert.That(1021, Is.EqualTo(refield3.Value)); } [Test] public void FieldNotFoundTest() { Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetString(99900); }); + delegate { _fieldmap.GetString(99900); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new DateTimeField(1002030)); }); + delegate { _fieldmap.GetField(new DateTimeField(1002030)); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new CharField(23099)); }); + delegate { _fieldmap.GetField(new CharField(23099)); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new BooleanField(99900)); }); + delegate { _fieldmap.GetField(new BooleanField(99900)); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new StringField(99900)); }); + delegate { _fieldmap.GetField(new StringField(99900)); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new IntField(99900)); }); + delegate { _fieldmap.GetField(new IntField(99900)); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetField(new DecimalField(99900)); }); + delegate { _fieldmap.GetField(new DecimalField(99900)); }); } [Test] @@ -327,11 +324,11 @@ public void AddGetGroupTest() Assert.That(fm.GetGroup(2, 100), Is.EqualTo(g2)); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetGroup(0, 101); }); + delegate { _fieldmap.GetGroup(0, 101); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetGroup(3, 100); }); + delegate { _fieldmap.GetGroup(3, 100); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetGroup(1, 101); }); + delegate { _fieldmap.GetGroup(1, 101); }); } [Test] @@ -346,18 +343,18 @@ public void RemoveGroupTest() Assert.That(fm.GetGroup(2, 100), Is.EqualTo(g2)); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.RemoveGroup(0, 101); }); + delegate { _fieldmap.RemoveGroup(0, 101); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.RemoveGroup(3, 100); }); + delegate { _fieldmap.RemoveGroup(3, 100); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.RemoveGroup(1, 101); }); + delegate { _fieldmap.RemoveGroup(1, 101); }); fm.RemoveGroup(1, 100); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetGroup(2, 100); }); + delegate { _fieldmap.GetGroup(2, 100); }); fm.RemoveGroup(1, 100); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.GetGroup(1, 100); }); + delegate { _fieldmap.GetGroup(1, 100); }); } [Test] @@ -373,11 +370,11 @@ public void ReplaceGroupTest() Group g3 = new Group(100, 202); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.ReplaceGroup(0, 101, g3); }); + delegate { _fieldmap.ReplaceGroup(0, 101, g3); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.ReplaceGroup(3, 100, g3); }); + delegate { _fieldmap.ReplaceGroup(3, 100, g3); }); Assert.Throws(typeof(FieldNotFoundException), - delegate { fieldmap.ReplaceGroup(1, 101, g3); }); + delegate { _fieldmap.ReplaceGroup(1, 101, g3); }); fm.ReplaceGroup(1, 100, g3); fm.ReplaceGroup(2, 100, g3); diff --git a/UnitTests/FieldTests.cs b/UnitTests/FieldTests.cs index c7554ace4..b650b5b4a 100644 --- a/UnitTests/FieldTests.cs +++ b/UnitTests/FieldTests.cs @@ -2,6 +2,7 @@ using NUnit.Framework; using QuickFix.Fields; using UnitTests.TestHelpers; +using StringField = QuickFix.Fields.StringField; namespace UnitTests { @@ -21,10 +22,10 @@ public void Tag() public void IntFieldTest() { IntField field = new IntField(Tags.AdvTransType, 500); - Assert.That(field.getValue(), Is.EqualTo(500)); + Assert.That(field.Value, Is.EqualTo(500)); Assert.That(field.Tag, Is.EqualTo(5)); Assert.That(field.ToString(), Is.EqualTo("500")); - Assert.That(field.Obj, Is.EqualTo(500)); + Assert.That(field.Value, Is.EqualTo(500)); Assert.That(field.Tag, Is.EqualTo(5)); field.Tag = 10; Assert.That(field.Tag, Is.EqualTo(10)); @@ -34,19 +35,19 @@ public void IntFieldTest() public void StringFieldTest() { StringField field = new StringField(200, "wayner"); - Assert.That(field.Obj, Is.EqualTo("wayner")); - Assert.That(field.getValue(), Is.EqualTo("wayner")); + Assert.That(field.Value, Is.EqualTo("wayner")); + Assert.That(field.Value, Is.EqualTo("wayner")); Assert.That(field.Tag, Is.EqualTo(200)); - field.setValue("galway"); - Assert.That(field.Obj, Is.EqualTo("galway")); + field.Value = "galway"; + Assert.That(field.Value, Is.EqualTo("galway")); } [Test] public void CharFieldTest() { CharField field = new CharField(200, '3'); - Assert.That(field.Obj, Is.EqualTo('3')); - Assert.That(field.getValue(), Is.EqualTo('3')); + Assert.That(field.Value, Is.EqualTo('3')); + Assert.That(field.Value, Is.EqualTo('3')); Assert.That(field.Tag, Is.EqualTo(200)); } @@ -56,22 +57,22 @@ public void DecimalFieldTest() Decimal val = new Decimal(3.232535); Decimal newval = new Decimal(3.14159); DecimalField field = new DecimalField(200, val); - Assert.That(field.Obj, Is.EqualTo(val)); - Assert.That(field.getValue(), Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); Assert.That(field.Tag, Is.EqualTo(200)); - field.Obj = newval; - Assert.That(field.Obj, Is.EqualTo(newval)); + field.Value = newval; + Assert.That(field.Value, Is.EqualTo(newval)); } [Test] public void BooleanFieldTest() { BooleanField field = new BooleanField(10, true); - Assert.That(field.Obj, Is.EqualTo(true)); - Assert.That(field.getValue(), Is.EqualTo(true)); + Assert.That(field.Value, Is.EqualTo(true)); + Assert.That(field.Value, Is.EqualTo(true)); Assert.That(field.Tag, Is.EqualTo(10)); - field.Obj = false; - Assert.That(field.Obj, Is.EqualTo(false)); + field.Value = false; + Assert.That(field.Value, Is.EqualTo(false)); } [Test] @@ -80,11 +81,11 @@ public void DateTimeFieldTest() DateTime val = new DateTime( 2009, 9, 4, 3, 44, 1 ); DateTime newval = new DateTime(2009, 9, 4, 3, 44, 1); DateTimeField field = new DateTimeField(200, val); - Assert.That(field.Obj, Is.EqualTo(val)); - Assert.That(field.getValue(), Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); Assert.That(field.Tag, Is.EqualTo(200)); - field.Obj = newval; - Assert.That(field.Obj, Is.EqualTo(newval)); + field.Value = newval; + Assert.That(field.Value, Is.EqualTo(newval)); Assert.That(field.ToString(), Is.EqualTo("20090904-03:44:01.000")); } @@ -94,66 +95,63 @@ public void DateTimeFieldNanoTest() DateTime val = TimeHelper.MakeDateTime(2009, 9, 4, 3, 44, 1, 100, 310, 300); DateTime newval = TimeHelper.MakeDateTime(2009, 9, 4, 3, 44, 1, 100, 310, 300); DateTimeField field = new DateTimeField(200, val, QuickFix.Fields.Converters.TimeStampPrecision.Nanosecond); - Assert.That(field.Obj, Is.EqualTo(val)); - Assert.That(field.getValue(), Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); + Assert.That(field.Value, Is.EqualTo(val)); Assert.That(field.Tag, Is.EqualTo(200)); - field.Obj = newval; - Assert.That(field.Obj, Is.EqualTo(newval)); + field.Value = newval; + Assert.That(field.Value, Is.EqualTo(newval)); Assert.That(field.ToString(), Is.EqualTo("20090904-03:44:01.100310300")); } [Test] public void StringFieldTest_TotalAndLength() { - /// - /// from quickfix/j FieldTest.java - /// StringField obj = new StringField(12, "VALUE"); - Assert.That(obj.toStringField(), Is.EqualTo("12=VALUE")); - Assert.That(obj.getTotal(), Is.EqualTo(542)); - Assert.That(obj.getLength(), Is.EqualTo(9)); - obj.Obj = "VALUF"; // F = E+1 - Assert.That(obj.toStringField(), Is.EqualTo("12=VALUF")); - Assert.That(obj.getTotal(), Is.EqualTo(543)); - Assert.That(obj.getLength(), Is.EqualTo(9)); + Assert.That(obj.ToStringField(), Is.EqualTo("12=VALUE")); + Assert.That(obj.GetTotal(), Is.EqualTo(542)); + Assert.That(obj.GetLength(), Is.EqualTo(9)); + obj.Value = "VALUF"; // F = E+1 + Assert.That(obj.ToStringField(), Is.EqualTo("12=VALUF")); + Assert.That(obj.GetTotal(), Is.EqualTo(543)); + Assert.That(obj.GetLength(), Is.EqualTo(9)); obj.Tag = 13; // 13 = 12+1 - Assert.That(obj.toStringField(), Is.EqualTo("13=VALUF")); - Assert.That(obj.getTotal(), Is.EqualTo(544)); - Assert.That(obj.getLength(), Is.EqualTo(9)); + Assert.That(obj.ToStringField(), Is.EqualTo("13=VALUF")); + Assert.That(obj.GetTotal(), Is.EqualTo(544)); + Assert.That(obj.GetLength(), Is.EqualTo(9)); // latin-1-specific character obj = new StringField(359, "olé!"); // the é is single-byte in iso-8859-1, but is 2 bytes in ascii or utf-8 - Assert.AreEqual(708, obj.getTotal()); // sum of all bytes in "359=olé!"+nul - Assert.AreEqual(9, obj.getLength()); // 8 single-byte chars + 1 nul char + Assert.AreEqual(708, obj.GetTotal()); // sum of all bytes in "359=olé!"+nul + Assert.AreEqual(9, obj.GetLength()); // 8 single-byte chars + 1 nul char } [Test] public void DefaultValTest() { BooleanField bf = new BooleanField(110); - Assert.That(false, Is.EqualTo(bf.Obj)); + Assert.That(false, Is.EqualTo(bf.Value)); Assert.That(110, Is.EqualTo(bf.Tag)); CharField cf = new CharField(300); - Assert.That('\0', Is.EqualTo(cf.getValue())); + Assert.That('\0', Is.EqualTo(cf.Value)); Assert.That(300, Is.EqualTo(cf.Tag)); DateTimeField dtf = new DateTimeField(3); Assert.That(3, Is.EqualTo(dtf.Tag)); StringField sf = new StringField(32); Assert.That(32, Is.EqualTo(sf.Tag)); - Assert.That("", Is.EqualTo(sf.Obj)); + Assert.That("", Is.EqualTo(sf.Value)); IntField ifld = new IntField(239); Assert.That(239, Is.EqualTo(ifld.Tag)); - Assert.That(0, Is.EqualTo(ifld.Obj)); + Assert.That(0, Is.EqualTo(ifld.Value)); DecimalField df = new DecimalField(1); Assert.That(1, Is.EqualTo(df.Tag)); - Assert.That(new Decimal(0.0), Is.EqualTo(df.Obj)); + Assert.That(new Decimal(0.0), Is.EqualTo(df.Value)); } [Test] public void AccountFieldTest() { Account acct = new Account("iiiD4"); - Assert.That("iiiD4", Is.EqualTo(acct.Obj)); + Assert.That("iiiD4", Is.EqualTo(acct.Value)); Assert.That(Tags.Account, Is.EqualTo(acct.Tag)); } @@ -161,11 +159,11 @@ public void AccountFieldTest() public void EnumFieldTest() { CommType ct = new CommType(CommType.PER_UNIT); - Assert.That('1', Is.EqualTo(ct.getValue())); + Assert.That('1', Is.EqualTo(ct.Value)); ExecInst ei = new ExecInst(ExecInst.STRICT_LIMIT); - Assert.That("b", Is.EqualTo(ei.getValue())); + Assert.That("b", Is.EqualTo(ei.Value)); AllocStatus ass = new AllocStatus(AllocStatus.REVERSED); - Assert.That(7, Is.EqualTo(ass.getValue())); + Assert.That(7, Is.EqualTo(ass.Value)); } [Test] diff --git a/UnitTests/GenMessageTest.cs b/UnitTests/GenMessageTest.cs index 0ae8ab1e7..0fa38f57d 100644 --- a/UnitTests/GenMessageTest.cs +++ b/UnitTests/GenMessageTest.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using NUnit.Framework; -using QuickFix; using QuickFix.Fields; namespace UnitTests @@ -11,88 +8,88 @@ namespace UnitTests public class GenMessageTests { [Test] - public void TCRFieldPropertiesTest() + public void TcrFieldPropertiesTest() { - Decimal val = new Decimal(3.232535); - QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport(); + decimal val = 3.232535m; + QuickFix.FIX44.TradeCaptureReport tcr = new(); tcr.AvgPx = new AvgPx(val); - Assert.That(tcr.AvgPx.getValue(), Is.EqualTo(val)); + Assert.That(tcr.AvgPx.Value, Is.EqualTo(val)); } [Test] - public void TCRFieldGetterTest() + public void TcrFieldGetterTest() { - AvgPx avgPx = new AvgPx(new Decimal(10.5)); + AvgPx avgPx = new AvgPx(10.5m); QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport(); tcr.SetField(avgPx); - Assert.That(tcr.AvgPx.getValue(), Is.EqualTo(avgPx.getValue())); + Assert.That(tcr.AvgPx.Value, Is.EqualTo(avgPx.Value)); AvgPx avgPx2 = new AvgPx(); tcr.GetField(avgPx2); - Assert.That(avgPx2.getValue(), Is.EqualTo(avgPx.getValue())); + Assert.That(avgPx2.Value, Is.EqualTo(avgPx.Value)); } [Test] - public void TCRFieldSetterTypeSafeOldWayTest() + public void TcrFieldSetterTypeSafeOldWayTest() { - AvgPx avgPx = new AvgPx(new Decimal(10.5)); + AvgPx avgPx = new AvgPx(10.5m); QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport(); tcr.Set(avgPx); - Assert.That(tcr.AvgPx.getValue(), Is.EqualTo(avgPx.getValue())); + Assert.That(tcr.AvgPx.Value, Is.EqualTo(avgPx.Value)); } [Test] - public void TCRFieldGetterTypeSafeOldWayTest() + public void TcrFieldGetterTypeSafeOldWayTest() { - AvgPx avgPx = new AvgPx(new Decimal(10.5)); + AvgPx avgPx = new AvgPx(10.5m); QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport(); - tcr.Set(new AvgPx(new Decimal(10.5))); + tcr.Set(new AvgPx(10.5m)); tcr.Get(avgPx); - Assert.That(tcr.AvgPx.getValue(), Is.EqualTo(avgPx.getValue())); + Assert.That(tcr.AvgPx.Value, Is.EqualTo(avgPx.Value)); } [Test] - public void TCRMsgTypeGetsSetTest() + public void TcrMsgTypeGetsSetTest() { QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport(); - Assert.That(tcr.Header.IsSetField(QuickFix.Fields.Tags.MsgType), Is.True); + Assert.That(tcr.Header.IsSetField(Tags.MsgType), Is.True); MsgType msgType = new MsgType(); tcr.Header.GetField(msgType); - Assert.That(msgType.getValue(), Is.EqualTo("AE")); + Assert.That(msgType.Value, Is.EqualTo("AE")); } [Test] - public void TCRReqFieldsCTORTest() + public void TcrReqFieldsCtorTest() { QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport( new TradeReportID("dude1"), new PreviouslyReported(true), new Symbol("AAPL"), - new LastQty(new Decimal(100.1)), - new LastPx(new Decimal(100.2)), + new LastQty(100.1m), + new LastPx(100.2m), new TradeDate("2010-12-12"), new TransactTime(new DateTime(2010, 12, 15, 10, 55, 32, 455))); - Assert.That(tcr.Symbol.getValue(), Is.EqualTo("AAPL")); - Assert.That(tcr.TradeReportID.getValue(), Is.EqualTo("dude1")); + Assert.That(tcr.Symbol.Value, Is.EqualTo("AAPL")); + Assert.That(tcr.TradeReportID.Value, Is.EqualTo("dude1")); MsgType msgType = new MsgType(); tcr.Header.GetField(msgType); - Assert.That(msgType.getValue(), Is.EqualTo("AE")); + Assert.That(msgType.Value, Is.EqualTo("AE")); } [Test] - public void TCRisSetTest() + public void TcrIsSetTest() { QuickFix.FIX44.TradeCaptureReport tcr = new QuickFix.FIX44.TradeCaptureReport( new TradeReportID("dude1"), new PreviouslyReported(true), new Symbol("AAPL"), - new LastQty(new Decimal(100.1)), - new LastPx(new Decimal(100.2)), + new LastQty(100.1m), + new LastPx(100.2m), new TradeDate("2010-12-12"), new TransactTime(new DateTime(2010, 12, 15, 10, 55, 32, 455))); LastPx lastPx = new LastPx(); Assert.That(tcr.IsSet(lastPx), Is.True); - AvgPx avgPx = new AvgPx(new Decimal(10.5)); + AvgPx avgPx = new AvgPx(10.5m); Assert.That(tcr.IsSet(avgPx), Is.False); Assert.That(tcr.IsSetAvgPx(), Is.False); tcr.Set(avgPx); @@ -102,31 +99,32 @@ public void TCRisSetTest() } [Test] - public void TCRGroupCTORTest() + public void TcrGroupCtorTest() { - int[] expFieldOrder = new int[] { - 54, 37, 198, 11, 526, 66, 453, 1, 660, 581, 81, 575, 576, + int[] expFieldOrder = + [ + 54, 37, 198, 11, 526, 66, 453, 1, 660, 581, 81, 575, 576, 635, 578, 579, 821, 15, 376, 377, 528, 529, 582, 40, 18, 483, 336, 625, 943, 12, 13, 479, 497, 381, 157, 230, 158, 159, 738, 920, 921, 922, 238, 237, 118, 119, 120, 155, 156, 77, 58, 354, 355, 752, 518, 232, 136, 825, 826, 591, 70, 78, 0 - }; + ]; QuickFix.FIX44.TradeCaptureReport.NoSidesGroup noSides = new QuickFix.FIX44.TradeCaptureReport.NoSidesGroup(); Assert.That(noSides.FieldOrder, Is.EqualTo(expFieldOrder)); Assert.That(QuickFix.FIX44.TradeCaptureReport.NoSidesGroup.fieldOrder, Is.EqualTo(expFieldOrder)); } [Test] - public void TCRGroupInGroupCTORTest() + public void TcrGroupInGroupCtorTest() { - int[] expFieldOrder = { 757, 758, 759, 806, 0 }; + int[] expFieldOrder = [757, 758, 759, 806, 0]; QuickFix.FIX44.TradeCaptureReport.NoSidesGroup.NoAllocsGroup.NoNested2PartyIDsGroup grp = new QuickFix.FIX44.TradeCaptureReport.NoSidesGroup.NoAllocsGroup.NoNested2PartyIDsGroup(); Assert.That(grp.FieldOrder, Is.EqualTo(expFieldOrder)); Assert.That(QuickFix.FIX44.TradeCaptureReport.NoSidesGroup.NoAllocsGroup.NoNested2PartyIDsGroup.fieldOrder, Is.EqualTo(expFieldOrder)); } [Test] - public void TCRGroupFieldGetterSetterTest() + public void TcrGroupFieldGetterSetterTest() { QuickFix.FIX44.TradeCaptureReport.NoSidesGroup noSides = new QuickFix.FIX44.TradeCaptureReport.NoSidesGroup(); OrderID ordId = new OrderID("fooey"); @@ -135,7 +133,7 @@ public void TCRGroupFieldGetterSetterTest() noSides.Set(ordId); Assert.That(noSides.IsSet(ordId), Is.True); Assert.That(noSides.IsSetOrderID(), Is.True); - Assert.That(noSides.OrderID.getValue(), Is.EqualTo("fooey")); + Assert.That(noSides.OrderID.Value, Is.EqualTo("fooey")); } } } diff --git a/UnitTests/GroupTests.cs b/UnitTests/GroupTests.cs index 419b4d70a..5daad06b9 100644 --- a/UnitTests/GroupTests.cs +++ b/UnitTests/GroupTests.cs @@ -50,8 +50,8 @@ public void GroupClone() QuickFix.FIX42.News.LinesOfTextGroup clone = linesGroup.Clone() as QuickFix.FIX42.News.LinesOfTextGroup; - Assert.AreEqual(linesGroup.Text.Obj, clone.Text.Obj); - Assert.AreEqual(linesGroup.EncodedText.Obj, clone.EncodedText.Obj); + Assert.AreEqual(linesGroup.Text.Value, clone.Text.Value); + Assert.AreEqual(linesGroup.EncodedText.Value, clone.EncodedText.Value); Assert.AreEqual(linesGroup.Delim, clone.Delim); Assert.AreEqual(linesGroup.CounterField, clone.CounterField); Assert.AreEqual(linesGroup.FieldOrder, clone.FieldOrder); diff --git a/UnitTests/MessageTests.cs b/UnitTests/MessageTests.cs index 34bc41241..132c666d4 100644 --- a/UnitTests/MessageTests.cs +++ b/UnitTests/MessageTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; - using NUnit.Framework; using QuickFix; using QuickFix.Fields; @@ -12,41 +11,39 @@ namespace UnitTests [TestFixture] public class MessageTests { - private IMessageFactory _defaultMsgFactory = new DefaultMessageFactory(); - - private const char Nul = Message.SOH; + private readonly IMessageFactory _defaultMsgFactory = new DefaultMessageFactory(); [Test] public void IdentifyTypeTest() { - string msg1 = "\x01" + "35=A\x01"; - Assert.That(Message.IdentifyType(msg1).Obj, Is.EqualTo(new MsgType("A").Obj)); - string msg2 = "a;sldkfjadls;k\x01" + "35=A\x01" + "a;sldkfja;sdlfk"; - Assert.That(Message.IdentifyType(msg2).Obj, Is.EqualTo(new MsgType("A").Obj)); - string msg3 = "8=FIX4.2\x01" + "9=12\x01\x01" + "35=B\x01" + "10=031\x01"; - Assert.That(Message.IdentifyType(msg3).Obj, Is.EqualTo(new MsgType("B").Obj)); + string msg1 = "|35=A|".Replace('|', Message.SOH); + Assert.That(Message.IdentifyType(msg1).Value, Is.EqualTo(new MsgType("A").Value)); + string msg2 = "a;sldkfjadls;k|35=A|a;sldkfja;sdlfk".Replace('|', Message.SOH); + Assert.That(Message.IdentifyType(msg2).Value, Is.EqualTo(new MsgType("A").Value)); + string msg3 = "8=FIX4.2|9=12||35=B|10=031|".Replace('|', Message.SOH); + Assert.That(Message.IdentifyType(msg3).Value, Is.EqualTo(new MsgType("B").Value)); // no 35 - string err1 = String.Join(Message.SOH, new string[] { "8=FIX.4.4", "49=Sender", "" }); + string err1 = "8=FIX.4.4|49=Sender|".Replace('|', Message.SOH); Assert.Throws(delegate { Message.IdentifyType(err1); }); // no SOH at end of 35 - string err2 = String.Join(Message.SOH, new string[] { "8=FIX.4.4", "35=A" }); + string err2 = "8=FIX.4.4|35=A".Replace('|', Message.SOH); Assert.Throws(delegate { Message.IdentifyType(err2); }); } [Test] public void ExtractStringTest() { - string str1 = "8=FIX.4.2\x01" + "9=46\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01"; + string str1 = "8=FIX.4.2|9=46|35=0|34=3|49=TW|".Replace('|', Message.SOH); int pos = 0; StringField sf1 = Message.ExtractField(str1, ref pos); Assert.That(pos, Is.EqualTo(10)); Assert.That(sf1.Tag, Is.EqualTo(8)); - Assert.That(sf1.Obj, Is.EqualTo("FIX.4.2")); + Assert.That(sf1.Value, Is.EqualTo("FIX.4.2")); StringField sf2 = Message.ExtractField(str1, ref pos); Assert.That(pos, Is.EqualTo(15)); Assert.That(sf2.Tag, Is.EqualTo(9)); - Assert.That(sf2.Obj, Is.EqualTo("46")); + Assert.That(sf2.Value, Is.EqualTo("46")); } [Test] @@ -67,12 +64,11 @@ public void ExtractStringErrorsTest() [Test] public void CheckSumTest() { - string str1 = "8=FIX.4.2\x01" + "9=45\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" + - "52=20000426-12:05:06\x01" + "56=ISLD\x01"; + string str1 = "8=FIX.4.2|9=45|35=0|34=3|49=TW|52=20000426-12:05:06|56=ISLD|".Replace('|', Message.SOH); int chksum = 0; foreach (char c in str1) - chksum += (int)c; + chksum += c; chksum %= 256; str1 += "10=218\x01"; // checksum field @@ -91,9 +87,10 @@ public void CheckSumTest() [Test] public void FromStringTestWithNoDataDictionary() { - string str1 = "8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" + - "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01"; - Message msg = new Message(); + string str1 = "8=FIX.4.2|9=55|35=0|34=3|49=TW|52=20000426-12:05:06|56=ISLD|1=acct123|10=123|" + .Replace('|', Message.SOH); + + Message msg = new(); try { msg.FromString(str1, true, null, null, _defaultMsgFactory); @@ -120,15 +117,15 @@ public void FromStringTestWithNoDataDictionary() msg.Header.GetField(f7); msg.GetField(f9); msg.Trailer.GetField(f8); - Assert.That(f1.Obj, Is.EqualTo("FIX.4.2")); - Assert.That(f2.Obj, Is.EqualTo("55")); - Assert.That(f3.Obj, Is.EqualTo("0")); - Assert.That(f4.Obj, Is.EqualTo("3")); - Assert.That(f5.Obj, Is.EqualTo("TW")); - Assert.That(f6.Obj, Is.EqualTo("20000426-12:05:06")); - Assert.That(f7.Obj, Is.EqualTo("ISLD")); - Assert.That(f8.Obj, Is.EqualTo("123")); - Assert.That(f9.Obj, Is.EqualTo("acct123")); + Assert.That(f1.Value, Is.EqualTo("FIX.4.2")); + Assert.That(f2.Value, Is.EqualTo("55")); + Assert.That(f3.Value, Is.EqualTo("0")); + Assert.That(f4.Value, Is.EqualTo("3")); + Assert.That(f5.Value, Is.EqualTo("TW")); + Assert.That(f6.Value, Is.EqualTo("20000426-12:05:06")); + Assert.That(f7.Value, Is.EqualTo("ISLD")); + Assert.That(f8.Value, Is.EqualTo("123")); + Assert.That(f9.Value, Is.EqualTo("acct123")); } [Test] @@ -138,25 +135,22 @@ public void FromString_Groups_NoFactory() var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); - string[] msgFields = { - // header - "8=FIX.4.4","9=638", "35=8", "34=360", "49=BLPTSOX", "52=20130321-15:21:23", "56=THINKTSOX", "57=6804469", "128=ZERO", - // non-group body fields - "6=122.255", "11=61101189", "14=1990000", "15=GBP", "17=VCON:20130321:50018:5:12", "22=4", "31=122.255", "32=1990000", - "37=116", "38=1990000", "39=2", "48=GB0032452392", "54=1", "55=[N/A]", "60=20130321-15:21:23", "64=20130322", "75=20130321", - "106=UK TSY 4 1/4% 2036", "118=2436321.85", "150=F", "151=0", "157=15", "159=3447.35", "192=0", "198=3739:20130321:50018:5", - "223=0.0425", "228=1", "236=0.0291371041", "238=0", "381=2432874.5", "423=1", "470=GB", "541=20360307", - // NoPartyIDs - "453=6", - "448=VCON", "447=D", "452=1", "802=1", "523=14", "803=4", - "448=TFOLIO:6804469", "447=D", "452=12", - "448=TFOLIO", "447=D", "452=11", - "448=THINKFOLIO LTD", "447=D", "452=13", - "448=SXT", "447=D", "452=16", - "448=TFOLIO:6804469", "447=D", "452=36", - "10=152" - }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + string msgStr = + ("8=FIX.4.4|9=638|35=8|34=360|49=BLPTSOX|52=20130321-15:21:23|56=THINKTSOX|57=6804469|128=ZERO|" + // non-group body fields + + "6=122.255|11=61101189|14=1990000|15=GBP|17=VCON:20130321:50018:5:12|22=4|31=122.255|32=1990000|" + + "37=116|38=1990000|39=2|48=GB0032452392|54=1|55=[N/A]|60=20130321-15:21:23|64=20130322|75=20130321|" + + "106=UK TSY 4 1/4% 2036|118=2436321.85|150=F|151=0|157=15|159=3447.35|192=0|198=3739:20130321:50018:5|" + + "223=0.0425|228=1|236=0.0291371041|238=0|381=2432874.5|423=1|470=GB|541=20360307|" + // NoPartyIDs + + "453=6|" + + "448=VCON|447=D|452=1|802=1|523=14|803=4|" + + "448=TFOLIO:6804469|447=D|452=12|" + + "448=TFOLIO|447=D|452=11|" + + "448=THINKFOLIO LTD|447=D|452=13|" + + "448=SXT|447=D|452=16|" + + "448=TFOLIO:6804469|447=D|452=36|" + + "10=152|").Replace('|', Message.SOH); QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport(); msg.FromString(msgStr, true, dd, dd, null); // <-- null factory! @@ -177,15 +171,14 @@ public void FromString_DoNotCorrectCounter() QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); - string nul = "\x01"; - string s = "8=FIX.4.2" + nul + "9=148" + nul + "35=D" + nul + "34=2" + nul + "49=TW" + nul + "52=20111011-15:06:23.103" + nul + "56=ISLD" + nul - + "11=ID" + nul + "21=1" + nul + "40=1" + nul + "54=1" + nul + "38=200.00" + nul + "55=INTC" + nul - + "386=3" + nul + "336=PRE-OPEN" + nul + "336=AFTER-HOURS" + nul - + "60=20111011-15:06:23.103" + nul - + "10=35" + nul; + string s = ("8=FIX.4.2|9=148|35=D|34=2|49=TW|52=20111011-15:06:23.103|56=ISLD|" + + "11=ID|21=1|40=1|54=1|38=200.00|55=INTC|" + + "386=3|336=PRE-OPEN|336=AFTER-HOURS|" + + "60=20111011-15:06:23.103|" + + "10=35|").Replace('|', Message.SOH); n.FromString(s, true, dd, dd, _defaultMsgFactory); - Assert.AreEqual("386=3", n.NoTradingSessions.toStringField()); + Assert.AreEqual("386=3", n.NoTradingSessions.ToStringField()); StringAssert.Contains("386=3", n.ConstructString()); //should not be "corrected" to 2! } @@ -198,13 +191,12 @@ public void FromString_GroupDelimiterIssue() QuickFix.FIX42.News n = new QuickFix.FIX42.News(); - string s = String.Join(Message.SOH, new string[]{ - "8=FIX.4.2", "9=91", "35=B", "34=2", "49=TW", "52=20111011-15:06:23.103", "56=ISLD", - "148=headline", "33=3", - "58=line1", "354=3", "355=uno", // first group, has delimiter - "354=3", "355=dos", // second group, missing delimiter - "354=4", "355=tres", // third group, also missing delimiter - "10=193" }) + Message.SOH; + string s = ("8=FIX.4.2|9=91|35=B|34=2|49=TW|52=20111011-15:06:23.103|56=ISLD|" + + "148=headline|33=3|" + + "58=line1|354=3|355=uno|" // first group, has delimiter + + "354=3|355=dos|" // second group, missing delimiter + + "354=4|355=tres|" // third group, also missing delimiter + + "10=193|").Replace('|', Message.SOH); Assert.Throws(delegate { n.FromString(s, true, dd, dd, _defaultMsgFactory); }); } @@ -213,12 +205,12 @@ public void FromString_GroupDelimiterIssue() public void ConstructStringFieldOrder() { Message msg = new Message(); - msg.Header.SetField(new QuickFix.Fields.MsgType("A")); - msg.Header.SetField(new QuickFix.Fields.BeginString("FIX.4.2")); - msg.Header.SetField(new QuickFix.Fields.SenderCompID("SENDER")); - msg.Header.SetField(new QuickFix.Fields.TargetCompID("TARGET")); - msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(42)); - string expect = "8=FIX.4.2\x01" + "9=31\x01" + "35=A\x01" + "34=42\x01" + "49=SENDER\x01" + "56=TARGET\x01" + "10=200\x01"; + msg.Header.SetField(new MsgType("A")); + msg.Header.SetField(new BeginString("FIX.4.2")); + msg.Header.SetField(new SenderCompID("SENDER")); + msg.Header.SetField(new TargetCompID("TARGET")); + msg.Header.SetField(new MsgSeqNum(42)); + string expect = "8=FIX.4.2|9=31|35=A|34=42|49=SENDER|56=TARGET|10=200|".Replace('|', Message.SOH); Assert.That(msg.ConstructString(), Is.EqualTo(expect)); } @@ -240,20 +232,22 @@ public void IsTrailerFieldTest() [Test] public void EnumeratorTest() { - Message msg = new Message("8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" + "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01"); + string msgStr = "8=FIX.4.2|9=55|35=0|34=3|49=TW|52=20000426-12:05:06|56=ISLD|1=acct123|10=123|" + .Replace('|', Message.SOH); + Message msg = new Message(msgStr); int numHeaderFields = 0; - foreach (KeyValuePair kvp in msg.Header) + foreach (KeyValuePair unused in msg.Header) ++numHeaderFields; Assert.AreEqual(7, numHeaderFields); int numTrailerFields = 0; - foreach (KeyValuePair kvp in msg.Trailer) + foreach (KeyValuePair unused in msg.Trailer) ++numTrailerFields; Assert.AreEqual(1, numTrailerFields); int numBodyFields = 0; - foreach (KeyValuePair kvp in msg) + foreach (KeyValuePair unused in msg) ++numBodyFields; Assert.AreEqual(1, numBodyFields); } @@ -261,7 +255,9 @@ public void EnumeratorTest() [Test] public void RepeatedTagDetection() { - Message msg = new Message("8=FIX.4.2\x01" + "9=72\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" + "49=BOGUS\x01" + "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "1=bogus\x01" + "10=052\x01" + "10=000\x01"); + string msgStr = ("8=FIX.4.2|9=72|35=0|34=3|49=TW|49=BOGUS|52=20000426-12:05:06|56=ISLD|" + + "1=acct123|1=bogus|10=052|10=000|").Replace('|', Message.SOH); + Message msg = new Message(msgStr); Assert.AreEqual(1, msg.Header.RepeatedTags.Count); Assert.AreEqual(49, msg.Header.RepeatedTags[0].Tag); @@ -290,15 +286,14 @@ public void AddGroupGetGroupTest() } [Test] - public void RepeatingGroupParseGroupTest() - { - String data = "8=FIX.4.4\x01" + "9=309\x01" + "35=8\x01" + "49=ASX\x01" + "56=CL1_FIX44\x01" + "34=4\x01" + "52=20060324-01:05:58\x01" + "" - + "17=X-B-WOW-1494E9A0:58BD3F9D-1109\x01" + "150=D\x01" + "39=0\x01" + "11=184271\x01" + "38=200\x01" + "198=1494E9A0:58BD3F9D\x01" + "" - + "526=4324\x01" + "37=B-WOW-1494E9A0:58BD3F9D\x01" + "55=WOW\x01" + "54=1\x01" + "151=200\x01" + "14=0\x01" + "40=2\x01" + "44=15\x01" + "59=1\x01" + "6=0\x01" + "" - + "453=3\x01" - + "448=AAA35791\x01" + "447=D\x01" + "452=3\x01" + "802=1\x01" + "523=OHAI123\x01" - + "448=8\x01" + "447=D\x01" + "452=4\x01" + "448=FIX11\x01" + "447=D\x01" + "452=36\x01" + "" - + "60=20060320-03:34:29\x01" + "10=169\x01" + ""; + public void RepeatingGroupParseGroupTest() { + string data = ("8=FIX.4.4|9=309|35=8|49=ASX|56=CL1_FIX44|34=4|52=20060324-01:05:58|" + + "17=X-B-WOW-1494E9A0:58BD3F9D-1109|150=D|39=0|11=184271|38=200|198=1494E9A0:58BD3F9D|" + + "526=4324|37=B-WOW-1494E9A0:58BD3F9D|55=WOW|54=1|151=200|14=0|40=2|44=15|59=1|6=0|" + + "453=3|" + + "448=AAA35791|447=D|452=3|802=1|523=OHAI123|" + + "448=8|447=D|452=4|448=FIX11|447=D|452=36|" + + "60=20060320-03:34:29|10=169|").Replace('|', Message.SOH); var msg = new QuickFix.FIX44.ExecutionReport(); var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); @@ -311,16 +306,15 @@ public void RepeatingGroupParseGroupTest() } [Test] - public void NestedRepeatingGroupParseGroupTest() - { - String data = "8=FIX.4.4\x01" + "9=309\x01" + "35=8\x01" + "49=ASX\x01" + "56=CL1_FIX44\x01" + "34=4\x01" + "52=20060324-01:05:58\x01" + "" - + "17=X-B-WOW-1494E9A0:58BD3F9D-1109\x01" + "150=D\x01" + "39=0\x01" + "11=184271\x01" + "38=200\x01" + "198=1494E9A0:58BD3F9D\x01" + "" - + "526=4324\x01" + "37=B-WOW-1494E9A0:58BD3F9D\x01" + "55=WOW\x01" + "54=1\x01" + "151=200\x01" + "14=0\x01" + "40=2\x01" + "44=15\x01" + "59=1\x01" + "6=0\x01" + "" - + "453=3\x01" - + "448=AAA35791\x01" + "447=D\x01" + "452=3\x01" + "802=1\x01" + "523=OHAI123\x01" - + "448=8\x01" + "447=D\x01" + "452=4\x01" - + "448=FIX11\x01" + "447=D\x01" + "452=36\x01" + "" - + "60=20060320-03:34:29\x01" + "10=169\x01" + ""; + public void NestedRepeatingGroupParseGroupTest() { + String data = ("8=FIX.4.4|9=309|35=8|49=ASX|56=CL1_FIX44|34=4|52=20060324-01:05:58|" + + "17=X-B-WOW-1494E9A0:58BD3F9D-1109|150=D|39=0|11=184271|38=200|198=1494E9A0:58BD3F9D|" + + "526=4324|37=B-WOW-1494E9A0:58BD3F9D|55=WOW|54=1|151=200|14=0|40=2|44=15|59=1|6=0|" + + "453=3|" + + "448=AAA35791|447=D|452=3|802=1|523=OHAI123|" + + "448=8|447=D|452=4|" + + "448=FIX11|447=D|452=36|" + + "60=20060320-03:34:29|10=169|").Replace('|', Message.SOH); var msg = new QuickFix.FIX44.ExecutionReport(); var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); @@ -339,19 +333,19 @@ public void ReadXmlDataTest() { QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); - string s = "8=FIX.4.2" + Nul + "9=495" + Nul + "35=n" + Nul + "34=31420" + Nul + "369=1003" + Nul + - "52=20200701-20:34:33.978" + Nul + "49=CME" + Nul + "50=84" + - Nul + "56=DUMMY11" + Nul + "57=SID1" + Nul + "143=US,IL" + Nul + "212=392" + Nul + - "213=8=FIX.4.2" + Nul + "9=356" + Nul + "35=8" + Nul + "34=36027" + Nul + - "369=18623" + Nul + "52=20200701-20:34:33.977" + Nul + "49=CME" + Nul + "50=84" + Nul + - "56=M2L000N" + Nul + "57=DUMMY" + Nul + "143=US,IL" + Nul + "1=00331" + Nul + - "6=0" + Nul + "11=ACP1593635673935" + Nul + "14=0" + Nul + "17=84618:1342652" + Nul + "20=0" + - Nul + "37=84778833500" + Nul + "38=10" + Nul + "39=0" + Nul + "40=2" + Nul + - "41=0" + Nul + "44=139.203125" + Nul + "48=204527" + Nul + "54=1" + Nul + "55=ZN" + Nul + - "59=0" + Nul + "60=20200701-20:34:33.976" + Nul + "107=ZNH1" + Nul + "150=0" + Nul + - "151=10" + Nul + "167=FUT" + Nul + "432=20200701" + Nul + "1028=Y" + Nul + "1031=Y" + Nul + - "5979=1593635673976364291" + Nul + "9717=ACP1593635673935" + Nul + "10=124" + Nul + "" + - Nul + "10=028" + Nul; + string s = ("8=FIX.4.2|9=495|35=n|34=31420|369=1003|" + + "52=20200701-20:34:33.978|49=CME|50=84|" + + "56=DUMMY11|57=SID1|143=US,IL|212=392|" + + "213=8=FIX.4.2|9=356|35=8|34=36027|" + + "369=18623|52=20200701-20:34:33.977|49=CME|50=84|" + + "56=M2L000N|57=DUMMY|143=US,IL|1=00331|" + + "6=0|11=ACP1593635673935|14=0|17=84618:1342652|20=0|" + + "37=84778833500|38=10|39=0|40=2|" + + "41=0|44=139.203125|48=204527|54=1|55=ZN|" + + "59=0|60=20200701-20:34:33.976|107=ZNH1|150=0|" + + "151=10|167=FUT|432=20200701|1028=Y|1031=Y|" + + "5979=1593635673976364291|9717=ACP1593635673935|10=124||" + + "10=028|").Replace('|', Message.SOH); n.FromString(s, true, dd, dd, _defaultMsgFactory); @@ -366,24 +360,22 @@ public void XmlDataWithoutLengthTest() { QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); - string s = "8=FIX.4.2" + Nul + "9=495" + Nul + "35=n" + Nul + "34=31420" + Nul + "369=1003" + Nul + - "52=20200701-20:34:33.978" + Nul + "49=CME" + Nul + "50=84" + - Nul + "56=DUMMY11" + Nul + "57=SID1" + Nul + "143=US,IL" + Nul + - "213=oops my length field 212 is missing" + - Nul + "10=028" + Nul; + string s = ("8=FIX.4.2|9=495|35=n|34=31420|369=1003|" + + "52=20200701-20:34:33.978|49=CME|50=84|" + + "56=DUMMY11|57=SID1|143=US,IL|" + + "213=oops my length field 212 is missing|" + + "10=028|").Replace('|', Message.SOH); FieldNotFoundException ex = Assert.Throws(delegate { n.FromString(s, true, dd, dd, _defaultMsgFactory); }); Assert.AreEqual("field not found for tag: 212", ex!.Message); } - [Test] public void HeaderGroupParsingTest() { - string data = "8=FIX.4.4\x01" + "9=40\x01" + "35=A\x01" - + "627=2\x01" + "628=FOO\x01" + "628=BAR\x01" - + "98=0\x01" + "384=2\x01" + "372=D\x01" + "385=R\x01" + "372=8\x01" + "385=S\x01" + "10=228\x01"; + string data = "8=FIX.4.4|9=40|35=A|627=2|628=FOO|628=BAR|98=0|384=2|372=D|385=R|372=8|385=S|10=228|" + .Replace('|', Message.SOH); QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); @@ -404,8 +396,8 @@ public void MsgType() [Test] public void ExtractBeginString() { - string m1 = "8=FIX4.2\x01" + "9999=99999\x01"; - string m2 = "987=pants\x01xxxxxxxxxxxxxxxxxxxxxx"; + string m1 = "8=FIX4.2|9999=99999|".Replace('|', Message.SOH);; + string m2 = "987=pants|xxxxxxxxxxxxxxxxxxxxxx".Replace('|', Message.SOH);; Assert.AreEqual("FIX4.2", Message.ExtractBeginString(m1)); Assert.AreEqual("pants", Message.ExtractBeginString(m2)); @@ -419,11 +411,11 @@ public void ExtractFieldTypes() QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); - string s = "8=FIX.4.2\x01" + "9=137\x01" + "35=D\x01" + "34=3\x01" + "49=CLIENT1\x01" - + "52=20110901-18:41:56.917\x01" + "56=EXECUTOR\x01" + "11=asdf\x01" + "21=1\x01" - + "38=5.5\x01" + "40=1\x01" + "54=1\x01" + "55=ibm\x01" + "59=1\x01" + "60=20110901-13:41:31.804\x01" - + "377=Y\x01" + "201=1\x01" - + "10=63\x01"; + string s = ("8=FIX.4.2|9=137|35=D|34=3|49=CLIENT1|" + + "52=20110901-18:41:56.917|56=EXECUTOR|11=asdf|21=1|" + + "38=5.5|40=1|54=1|55=ibm|59=1|60=20110901-13:41:31.804|" + + "377=Y|201=1|" + + "10=63|").Replace('|', Message.SOH); n.FromString(s, true, dd, dd, _defaultMsgFactory); // string values are good? @@ -435,87 +427,81 @@ public void ExtractFieldTypes() Assert.AreEqual("asdf", n.ClOrdID.ToString()); //string, 11 // type-converted values are good? - Assert.AreEqual(true, n.SolicitedFlag.getValue()); - Assert.AreEqual('1', n.Side.getValue()); - Assert.AreEqual(DateTime.Parse("2011-09-01 13:41:31.804"), n.TransactTime.getValue()); - Assert.AreEqual(5.5m, n.OrderQty.getValue()); - Assert.AreEqual(1, n.PutOrCall.getValue()); - Assert.AreEqual("asdf", n.ClOrdID.getValue()); + Assert.AreEqual(true, n.SolicitedFlag.Value); + Assert.AreEqual('1', n.Side.Value); + Assert.AreEqual(DateTime.Parse("2011-09-01 13:41:31.804"), n.TransactTime.Value); + Assert.AreEqual(5.5m, n.OrderQty.Value); + Assert.AreEqual(1, n.PutOrCall.Value); + Assert.AreEqual("asdf", n.ClOrdID.Value); } [Test] public void ExtractFieldTest() { - string msgstr = "100=200\x01" + "300=400\x01" + "500=600\x01"; + string msgstr = "100=200|300=400|500=600|".Replace('|', Message.SOH); int n = 0; var x = QuickFix.Message.ExtractField(msgstr, ref n); Assert.AreEqual(8, n); - Assert.AreEqual("100=200", x.toStringField()); + Assert.AreEqual("100=200", x.ToStringField()); x = QuickFix.Message.ExtractField(msgstr, ref n); Assert.AreEqual(16, n); - Assert.AreEqual("300=400", x.toStringField()); + Assert.AreEqual("300=400", x.ToStringField()); x = QuickFix.Message.ExtractField(msgstr, ref n); Assert.AreEqual(24, n); - Assert.AreEqual("500=600", x.toStringField()); + Assert.AreEqual("500=600", x.ToStringField()); } [Test] public void RepeatingGroup() { - QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); + QuickFix.DataDictionary.DataDictionary dd = new(); dd.LoadFIXSpec("FIX42"); - QuickFix.FIX42.News news = new QuickFix.FIX42.News(new QuickFix.Fields.Headline("Foo headline")); + QuickFix.FIX42.News news = new QuickFix.FIX42.News(new Headline("Foo headline")); - QuickFix.FIX42.News.LinesOfTextGroup group1 = new QuickFix.FIX42.News.LinesOfTextGroup(); - group1.Text = new QuickFix.Fields.Text("line1"); - group1.EncodedTextLen = new QuickFix.Fields.EncodedTextLen(3); - group1.EncodedText = new QuickFix.Fields.EncodedText("aaa"); + QuickFix.FIX42.News.LinesOfTextGroup group1 = new(); + group1.Text = new Text("line1"); + group1.EncodedTextLen = new EncodedTextLen(3); + group1.EncodedText = new EncodedText("aaa"); news.AddGroup(group1); - QuickFix.FIX42.News.LinesOfTextGroup group2 = new QuickFix.FIX42.News.LinesOfTextGroup(); - group2.Text = new QuickFix.Fields.Text("line2"); - group2.EncodedText = new QuickFix.Fields.EncodedText("bbb"); + QuickFix.FIX42.News.LinesOfTextGroup group2 = new(); + group2.Text = new Text("line2"); + group2.EncodedText = new EncodedText("bbb"); news.AddGroup(group2); string raw = news.ConstructString(); - string nul = "\x01"; - StringAssert.Contains( - nul + "33=2" + nul + "58=line1" + nul + "354=3" + nul + "355=aaa" + nul + "58=line2" + nul + "355=bbb", - raw); + StringAssert.Contains("33=2|58=line1|354=3|355=aaa|58=line2|355=bbb|", raw.Replace(Message.SOH, '|')); } [Test] public void RepeatingGroup_ReuseObject() { - QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); + QuickFix.DataDictionary.DataDictionary dd = new(); dd.LoadFIXSpec("FIX42"); - QuickFix.FIX42.News news = new QuickFix.FIX42.News(new QuickFix.Fields.Headline("Foo headline")); + QuickFix.FIX42.News news = new QuickFix.FIX42.News(new Headline("Foo headline")); - QuickFix.FIX42.News.LinesOfTextGroup group = new QuickFix.FIX42.News.LinesOfTextGroup(); - group.Text = new QuickFix.Fields.Text("line1"); + QuickFix.FIX42.News.LinesOfTextGroup group = new(); + group.Text = new Text("line1"); news.AddGroup(group); - group.Text = new QuickFix.Fields.Text("line2"); + group.Text = new Text("line2"); news.AddGroup(group); string raw = news.ConstructString(); - - string nul = "\x01"; - StringAssert.Contains( - nul + "33=2" + nul + "58=line1" + nul + "58=line2", - raw); + StringAssert.Contains("|33=2|58=line1|58=line2|", raw.Replace(Message.SOH, '|')); } [Test] public void ReverseRoute() { - string str1 = "8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" + - "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01"; + string str1 = "8=FIX.4.2|9=55|35=0|34=3|49=TW|52=20000426-12:05:06|56=ISLD|1=acct123|10=123|" + .Replace('|', Message.SOH); + Message msg = new Message(); try { @@ -546,12 +532,12 @@ public void ReverseRoute() } [Test] - public void TestGetSetSessionID() + public void TestGetSetSessionId() { - SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "SENDERSUB", "SENDERLOC", "TARGET", "TARGETSUB", "TARGETLOC"); + SessionID sessionId = new SessionID("FIX.4.2", "SENDER", "SENDERSUB", "SENDERLOC", "TARGET", "TARGETSUB", "TARGETLOC"); Message msg = new Message(); - msg.SetSessionID(sessionID); + msg.SetSessionID(sessionId); Assert.That(msg.Header.GetString(Tags.BeginString), Is.EqualTo("FIX.4.2")); Assert.That(msg.Header.GetString(Tags.SenderCompID), Is.EqualTo("SENDER")); @@ -561,20 +547,20 @@ public void TestGetSetSessionID() Assert.That(msg.Header.GetString(Tags.TargetSubID), Is.EqualTo("TARGETSUB")); Assert.That(msg.Header.GetString(Tags.TargetLocationID), Is.EqualTo("TARGETLOC")); - SessionID getSessionID = msg.GetSessionID(msg); - Assert.That(getSessionID.BeginString, Is.EqualTo("FIX.4.2")); - Assert.That(getSessionID.SenderCompID, Is.EqualTo("SENDER")); - Assert.That(getSessionID.SenderSubID, Is.EqualTo("SENDERSUB")); - Assert.That(getSessionID.SenderLocationID, Is.EqualTo("SENDERLOC")); - Assert.That(getSessionID.TargetCompID, Is.EqualTo("TARGET")); - Assert.That(getSessionID.TargetSubID, Is.EqualTo("TARGETSUB")); - Assert.That(getSessionID.TargetLocationID, Is.EqualTo("TARGETLOC")); + SessionID getSessionId = msg.GetSessionID(msg); + Assert.That(getSessionId.BeginString, Is.EqualTo("FIX.4.2")); + Assert.That(getSessionId.SenderCompID, Is.EqualTo("SENDER")); + Assert.That(getSessionId.SenderSubID, Is.EqualTo("SENDERSUB")); + Assert.That(getSessionId.SenderLocationID, Is.EqualTo("SENDERLOC")); + Assert.That(getSessionId.TargetCompID, Is.EqualTo("TARGET")); + Assert.That(getSessionId.TargetSubID, Is.EqualTo("TARGETSUB")); + Assert.That(getSessionId.TargetLocationID, Is.EqualTo("TARGETLOC")); //// - sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET"); + sessionId = new SessionID("FIX.4.2", "SENDER", "TARGET"); msg = new Message(); - msg.SetSessionID(sessionID); + msg.SetSessionID(sessionId); Assert.That(msg.Header.GetString(Tags.BeginString), Is.EqualTo("FIX.4.2")); Assert.That(msg.Header.GetString(Tags.SenderCompID), Is.EqualTo("SENDER")); @@ -584,47 +570,44 @@ public void TestGetSetSessionID() Assert.That(msg.Header.IsSetField(Tags.TargetSubID), Is.False); Assert.That(msg.Header.IsSetField(Tags.TargetLocationID), Is.False); - getSessionID = msg.GetSessionID(msg); - Assert.That(getSessionID.BeginString, Is.EqualTo("FIX.4.2")); - Assert.That(getSessionID.SenderCompID, Is.EqualTo("SENDER")); - Assert.That(getSessionID.SenderSubID, Is.EqualTo("")); - Assert.That(getSessionID.SenderLocationID, Is.EqualTo("")); - Assert.That(getSessionID.TargetCompID, Is.EqualTo("TARGET")); - Assert.That(getSessionID.TargetSubID, Is.EqualTo("")); - Assert.That(getSessionID.TargetLocationID, Is.EqualTo("")); + getSessionId = msg.GetSessionID(msg); + Assert.That(getSessionId.BeginString, Is.EqualTo("FIX.4.2")); + Assert.That(getSessionId.SenderCompID, Is.EqualTo("SENDER")); + Assert.That(getSessionId.SenderSubID, Is.EqualTo("")); + Assert.That(getSessionId.SenderLocationID, Is.EqualTo("")); + Assert.That(getSessionId.TargetCompID, Is.EqualTo("TARGET")); + Assert.That(getSessionId.TargetSubID, Is.EqualTo("")); + Assert.That(getSessionId.TargetLocationID, Is.EqualTo("")); } [Test] - public void GetMsgTypeTest() - { - string[] msgFields = { "8=FIX.4.4", "9=104", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", - "55=sym", "268=1", "269=0", "272=20111012", "273=22:15:30.444", "10=19" }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + public void GetMsgTypeTest() { + string msgStr = ("8=FIX.4.4|9=104|35=W|34=3|49=sender|52=20110909-09:09:09.999|56=target" + + "55=sym|268=1|269=0|272=20111012|273=22:15:30.444|10=19|").Replace('|', Message.SOH); Assert.AreEqual("W", Message.GetMsgType(msgStr)); // invalid 35 value, let it ride - string[] msgFields2 = { "8=FIX.4.4", "9=68", "35=*", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", - "55=sym", "268=0", "10=9" }; - string msgStr2 = String.Join(Message.SOH, msgFields2) + Message.SOH; + string msgStr2 = ("8=FIX.4.4|9=68|35=*|34=3|49=sender|52=20110909-09:09:09.999|56=target" + + "55=sym|268=0|10=9|").Replace('|', Message.SOH); Assert.AreEqual("*", Message.GetMsgType(msgStr2)); } [Test] public void RepeatingGroup_DelimiterFieldFirst() { - QuickFix.FIX44.MarketDataRequest msg = new QuickFix.FIX44.MarketDataRequest(); + QuickFix.FIX44.MarketDataRequest msg = new(); msg.MDReqID = new MDReqID("fooMdReqID"); msg.SubscriptionRequestType = new SubscriptionRequestType('1'); msg.MarketDepth = new MarketDepth(0); // this group is irrelevant to the test, but it's required in the message - QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup entryTypesGroup = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup(); + QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup entryTypesGroup = new(); entryTypesGroup.MDEntryType = new MDEntryType('0'); msg.AddGroup(entryTypesGroup); entryTypesGroup.MDEntryType = new MDEntryType('1'); msg.AddGroup(entryTypesGroup); - QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symGroup = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup(); + QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symGroup = new(); symGroup.Symbol = new Symbol("FOO1"); symGroup.SecurityID = new SecurityID("secid1"); msg.AddGroup(symGroup); @@ -633,7 +616,7 @@ public void RepeatingGroup_DelimiterFieldFirst() msg.AddGroup(symGroup); string msgString = msg.ConstructString(); - string expected = String.Join(Message.SOH, new string[] { "146=2", "55=FOO1", "48=secid1", "55=FOO2", "48=secid2" }); + string expected = "146=2|55=FOO1|48=secid1|55=FOO2|48=secid2|".Replace('|', Message.SOH); StringAssert.Contains(expected, msgString); } @@ -641,19 +624,19 @@ public void RepeatingGroup_DelimiterFieldFirst() [Test] public void RepeatingGroup_FieldOrder() { - QuickFix.FIX44.MarketDataRequest msg = new QuickFix.FIX44.MarketDataRequest(); + QuickFix.FIX44.MarketDataRequest msg = new(); msg.MDReqID = new MDReqID("fooMdReqID"); msg.SubscriptionRequestType = new SubscriptionRequestType('1'); msg.MarketDepth = new MarketDepth(0); // this group is irrelevant to the test, but it's required in the message - QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup entryTypesGroup = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup(); + QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup entryTypesGroup = new(); entryTypesGroup.MDEntryType = new MDEntryType('0'); msg.AddGroup(entryTypesGroup); entryTypesGroup.MDEntryType = new MDEntryType('1'); msg.AddGroup(entryTypesGroup); - QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symGroup = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup(); + QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symGroup = new(); // spec order of fields is 55,65,48,22 symGroup.Symbol = new Symbol("FOO1"); symGroup.SymbolSfx = new SymbolSfx("sfx1"); @@ -667,10 +650,8 @@ public void RepeatingGroup_FieldOrder() msg.AddGroup(symGroup); string msgString = msg.ConstructString(); - string expected = String.Join(Message.SOH, new string[] { "146=2", - "55=FOO1", "65=sfx1", "48=secid1", "22=src1", - "55=FOO2", "65=sfx2", "48=secid2", "22=src2", - }); + string expected = "146=2|55=FOO1|65=sfx1|48=secid1|22=src1|55=FOO2|65=sfx2|48=secid2|22=src2|" + .Replace('|', Message.SOH); StringAssert.Contains(expected, msgString); } @@ -678,7 +659,7 @@ public void RepeatingGroup_FieldOrder() [Test] public void ConstructString_FIX50() { - QuickFix.FIX50.News msg = new QuickFix.FIX50.News(); + QuickFix.FIX50.News msg = new(); msg.Headline = new Headline("FOO"); StringAssert.StartsWith("8=FIXT.1.1" + Message.SOH, msg.ConstructString()); @@ -689,22 +670,22 @@ public void RepeatingGroup_SubgroupCounterTagAppearsOnlyOnce() { // issue #11 bug, as reported by karabiberoglu's further-down post - QuickFix.FIX44.CollateralInquiry ci = new QuickFix.FIX44.CollateralInquiry(); - ci.CollInquiryID = new QuickFix.Fields.CollInquiryID("CollateralInquiry"); + QuickFix.FIX44.CollateralInquiry ci = new(); + ci.CollInquiryID = new CollInquiryID("CollateralInquiry"); // group - QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup noParty = new QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup(); - noParty.PartyID = new QuickFix.Fields.PartyID("ABC"); - noParty.PartyIDSource = new QuickFix.Fields.PartyIDSource(QuickFix.Fields.PartyIDSource.PROPRIETARY_CUSTOM_CODE); - noParty.PartyRole = new QuickFix.Fields.PartyRole(QuickFix.Fields.PartyRole.CLEARING_FIRM); + QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup noParty = new(); + noParty.PartyID = new PartyID("ABC"); + noParty.PartyIDSource = new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE); + noParty.PartyRole = new PartyRole(PartyRole.CLEARING_FIRM); // group in group - QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup.NoPartySubIDsGroup noPartySub = new QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup.NoPartySubIDsGroup(); - noPartySub.PartySubID = new QuickFix.Fields.PartySubID("subABC"); - noPartySub.PartySubIDType = new QuickFix.Fields.PartySubIDType(QuickFix.Fields.PartySubIDType.FIRM); + QuickFix.FIX44.CollateralInquiry.NoPartyIDsGroup.NoPartySubIDsGroup noPartySub = new(); + noPartySub.PartySubID = new PartySubID("subABC"); + noPartySub.PartySubIDType = new PartySubIDType(PartySubIDType.FIRM); noParty.AddGroup(noPartySub); - noPartySub.PartySubID = new QuickFix.Fields.PartySubID("subDEF"); - noPartySub.PartySubIDType = new QuickFix.Fields.PartySubIDType(QuickFix.Fields.PartySubIDType.LOCATION); + noPartySub.PartySubID = new PartySubID("subDEF"); + noPartySub.PartySubIDType = new PartySubIDType(PartySubIDType.LOCATION); noParty.AddGroup(noPartySub); ci.AddGroup(noParty); @@ -725,13 +706,14 @@ public void RepeatingGroup_SubgroupCounterTagAppearsOnlyOnce() } [Test] - public void issue56_GetGroup_by_tag_and_return() + public void Issue56_GetGroup_by_tag_and_return() { // setup var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); - string[] msgFields = { "8=FIX.4.2", "9=87", "35=B", "34=3", "49=CLIENT1", "52=20111012-22:15:55.474", "56=EXECUTOR", "148=AAAAAAA", "33=2", "58=L1", "58=L2", "10=016" }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + + string msgStr = ("8=FIX.4.2|9=87|35=B|34=3|49=CLIENT1|52=20111012-22:15:55.474|56=EXECUTOR|" + + "148=AAAAAAA|33=2|58=L1|58=L2|10=016|").Replace('|', Message.SOH); QuickFix.FIX42.News msg = new QuickFix.FIX42.News(); msg.FromString(msgStr, false, dd, dd, _defaultMsgFactory); Assert.AreEqual(2, msg.GroupCount(Tags.LinesOfText)); // for sanity @@ -739,21 +721,22 @@ public void issue56_GetGroup_by_tag_and_return() // the test var grp1 = msg.GetGroup(1, Tags.LinesOfText); Assert.IsInstanceOf(grp1); - Assert.AreEqual("L1", (grp1 as QuickFix.FIX42.News.LinesOfTextGroup).Text.Obj); + Assert.AreEqual("L1", (grp1 as QuickFix.FIX42.News.LinesOfTextGroup)!.Text.Value); var grp2 = msg.GetGroup(2, Tags.LinesOfText); Assert.IsInstanceOf(grp2); - Assert.AreEqual("L2", (grp2 as QuickFix.FIX42.News.LinesOfTextGroup).Text.Obj); + Assert.AreEqual("L2", (grp2 as QuickFix.FIX42.News.LinesOfTextGroup)!.Text.Value); } [Test] - public void issue56_GetGroup_by_reference() + public void Issue56_GetGroup_by_reference() { // setup var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); - string[] msgFields = { "8=FIX.4.2", "9=87", "35=B", "34=3", "49=CLIENT1", "52=20111012-22:15:55.474", "56=EXECUTOR", "148=AAAAAAA", "33=2", "58=L1", "58=L2", "10=016" }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + + string msgStr = ("8=FIX.4.2|9=87|35=B|34=3|49=CLIENT1|52=20111012-22:15:55.474|56=EXECUTOR|" + + "148=AAAAAAA|33=2|58=L1|58=L2|10=016|").Replace('|', Message.SOH); QuickFix.FIX42.News msg = new QuickFix.FIX42.News(); msg.FromString(msgStr, false, dd, dd, _defaultMsgFactory); Assert.AreEqual(2, msg.GroupCount(Tags.LinesOfText)); // for sanity @@ -762,10 +745,10 @@ public void issue56_GetGroup_by_reference() QuickFix.FIX42.News.LinesOfTextGroup grp = new QuickFix.FIX42.News.LinesOfTextGroup(); // for return value msg.GetGroup(1, grp); - Assert.AreEqual("L1", grp.Text.Obj); + Assert.AreEqual("L1", grp.Text.Value); msg.GetGroup(2, grp); - Assert.AreEqual("L2", grp.Text.Obj); + Assert.AreEqual("L2", grp.Text.Value); } [Test] @@ -773,20 +756,19 @@ public void MissingDelimiterField() { // issue 101 - var dd = new QuickFix.DataDictionary.DataDictionary(); + QuickFix.DataDictionary.DataDictionary dd = new(); dd.LoadFIXSpec("FIX44"); // message is missing 703 - string[] msgFields = { "8=FIX.4.4", "9=230", "35=AP", "34=3", "49=XXXXX", "52=20120731-14:06:37.848", "56=FixKevindemo", - "1=20050500001", "55=EURUSD", "453=0", "581=1", "702=1", "704=0", "705=20000", "710=634792896000000000", "715=20120802", - "721=P-DEA30E1PHC0IW7V", "730=1.22608", "731=1", "734=1.22608", "753=1", "708=20000", "10=030" - }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + string msgStr = ("8=FIX.4.4|9=230|35=AP|34=3|49=XXXXX|52=20120731-14:06:37.848|56=FixKevindemo" + + "1=20050500001|55=EURUSD|453=0|581=1|702=1|704=0|705=20000|710=634792896000000000|715=20120802" + + "721=P-DEA30E1PHC0IW7V|730=1.22608|731=1|734=1.22608|753=1|708=20000|10=030|") + .Replace('|', Message.SOH); - QuickFix.FIX44.PositionReport msg = new QuickFix.FIX44.PositionReport(); + QuickFix.FIX44.PositionReport msg = new(); - QuickFix.GroupDelimiterTagException ex = - Assert.Throws(delegate { msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); }); + GroupDelimiterTagException ex = + Assert.Throws(delegate { msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); })!; Assert.AreEqual(702, ex.Field); Assert.AreEqual("Group 702's first entry does not start with delimiter 703", ex.Message); } @@ -796,39 +778,37 @@ public void DateOnlyTimeOnlyConvertProblem() { // issue 135 - var dd = new QuickFix.DataDictionary.DataDictionary(); + QuickFix.DataDictionary.DataDictionary dd = new(); dd.LoadFIXSpec("FIX44"); - string[] msgFields = { "8=FIX.4.4", "9=332", "35=W", "34=2", "49=MA", "52=20121024-12:21:42.170", "56=xxxx", - "22=4", "48=BE0932900518", "55=[N/A]", "262=1b145288-9c9a-4911-a084-7341c69d3e6b", "762=EURO_EUR", "268=2", - "269=0", "270=97.625", "15=EUR", "271=1246000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15478575", - "269=1", "270=108.08", "15=EUR", "271=884000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15467902", "10=77" - }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + string msgStr = ("8=FIX.4.4|9=332|35=W|34=2|49=MA|52=20121024-12:21:42.170|56=xxxx|" + + "22=4|48=BE0932900518|55=[N/A]|262=1b145288-9c9a-4911-a084-7341c69d3e6b|762=EURO_EUR|268=2|" + + "269=0|270=97.625|15=EUR|271=1246000|272=20121024|273=07:30:47|276=I|282=BEARGB21XXX|299=15478575|" + + "269=1|270=108.08|15=EUR|271=884000|272=20121024|273=07:30:47|276=I|282=BEARGB21XXX|299=15467902|10=77|") + .Replace('|', Message.SOH); - QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new QuickFix.FIX44.MarketDataSnapshotFullRefresh(); + QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new(); msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); - QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup gentry1 = new QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup(); + QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup gentry1 = new(); msg.GetGroup(1, gentry1); - Assert.AreEqual(new DateTime(2012, 10, 24), gentry1.MDEntryDate.getValue()); - Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47).TimeOfDay, gentry1.MDEntryTime.getValue().TimeOfDay); - Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47), gentry1.MDEntryDate.getValue() + gentry1.MDEntryTime.getValue().TimeOfDay); + Assert.AreEqual(new DateTime(2012, 10, 24), gentry1.MDEntryDate.Value); + Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47).TimeOfDay, gentry1.MDEntryTime.Value.TimeOfDay); + Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47), gentry1.MDEntryDate.Value + gentry1.MDEntryTime.Value.TimeOfDay); } [Test] public void SendDateOnlyTimeOnlyConvertProblem() { // issue 135 - QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new QuickFix.FIX44.MarketDataSnapshotFullRefresh(); + QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new(); msg.MDReqID = new MDReqID("1b145288-9c9a-4911-a084-7341c69d3e6b"); msg.Symbol = new Symbol("[N/A]"); msg.SecurityIDSource = new SecurityIDSource(SecurityIDSource.ISIN_NUMBER); msg.SecurityID = new SecurityID("BE0932900518"); msg.SecuritySubType = new SecuritySubType("EURO_EUR"); msg.NoMDEntries = new NoMDEntries(2); - QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup grp = - new QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup(); + QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup grp = new(); grp.MDEntryType = new MDEntryType(MDEntryType.BID); grp.MDEntryPx = new MDEntryPx((decimal)97.625); grp.Currency = new Currency("EUR"); @@ -854,10 +834,11 @@ public void SendDateOnlyTimeOnlyConvertProblem() string msgString = msg.ConstructString(); - string expected = String.Join(Message.SOH, new string[] { "35=W", "22=4", "48=BE0932900518", "55=[N/A]", "262=1b145288-9c9a-4911-a084-7341c69d3e6b", "762=EURO_EUR", "268=2", - "269=0", "270=97.625", "15=EUR", "271=1246000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15478575", - "269=1", "270=108.08", "15=EUR", "271=884000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15467902" - }); + string expected = + ("35=W|22=4|48=BE0932900518|55=[N/A]|262=1b145288-9c9a-4911-a084-7341c69d3e6b|762=EURO_EUR|268=2|" + + "269=0|270=97.625|15=EUR|271=1246000|272=20121024|273=07:30:47|276=I|282=BEARGB21XXX|299=15478575|" + + "269=1|270=108.08|15=EUR|271=884000|272=20121024|273=07:30:47|276=I|282=BEARGB21XXX|299=15467902|") + .Replace('|', Message.SOH); StringAssert.Contains(expected, msgString); } @@ -869,17 +850,15 @@ public void MessageHasDecimalWithNoLeadingZero() var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); - string[] msgFields = { "8=FIX.4.4", "9=122", "35=8", "34=2", "49=sender", "52=20121024-12:21:42.170", "56=target", - "37=orderid", "17=execid", "150=0", "39=0", - "55=ibm", "228=.23", // Instrument component; 228 is a float type in the spec - "54=1", "151=1", "14=1", "6=1", "10=45" - }; - string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; + string msgStr = ("8=FIX.4.4|9=122|35=8|34=2|49=sender|52=20121024-12:21:42.170|56=target|" + + "37=orderid|17=execid|150=0|39=0|" + + "55=ibm|228=.23|" // Instrument component; 228 is a float type in the spec + + "54=1|151=1|14=1|6=1|10=45|").Replace('|', Message.SOH); QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport(); msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); - Assert.AreEqual(0.23, msg.Factor.getValue()); + Assert.AreEqual(0.23, msg.Factor.Value); } [Test] @@ -889,36 +868,32 @@ public void IsAdmin_IsApp() var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX42"); - string[] newsFields = { "8=FIX4.2", "9=5", "35=B", "10=133" }; - string newsStr = String.Join(Message.SOH, newsFields) + Message.SOH; + string newsStr = "8=FIX4.2|9=5|35=B|10=133|".Replace('|', Message.SOH); QuickFix.FIX42.News news = new QuickFix.FIX42.News(); news.FromString(newsStr, true, dd, dd, _defaultMsgFactory); - string[] hbFields = { "8=FIX.4.2", "9=16", "35=0", "34=3", "49=TW", "10=1" }; - string hbStr = String.Join(Message.SOH, hbFields) + Message.SOH; + string hbStr = "8=FIX.4.2|9=16|35=0|34=3|49=TW|10=1|".Replace('|', Message.SOH); QuickFix.FIX42.Heartbeat heartbeat = new QuickFix.FIX42.Heartbeat(); heartbeat.FromString(hbStr, true, dd, dd, _defaultMsgFactory); Assert.False(news.IsAdmin()); - //Assert.True(news.IsApp()); + Assert.True(news.IsApp()); - //Assert.True(heartbeat.IsAdmin()); + Assert.True(heartbeat.IsAdmin()); Assert.False(heartbeat.IsApp()); } [Test] - public void issue95() + public void TripleNestedGroups_Issue95() { // Parser screws up on triple-nested groups. Contributes to ResendRequest failures. - string msgStr = String.Join(Message.SOH, new string[]{ - "8=FIX.4.4","9=999","35=R","34=6","49=sendercompid","52=20130225-10:44:59.149","56=targetcompid", //headers - "131=quotereqid", - "146=1", // NoRelatedSym - "55=ABC","65=CD","48=securityid","22=1", // group - "711=1", // NoUnderlyings - "311=underlyingsymbol","312=WI","309=underlyingsecurityid","305=1", - "10=999","" - }); + string msgStr = ("8=FIX.4.4|9=999|35=R|34=6|49=sendercompid|52=20130225-10:44:59.149|56=targetcompid|" + + "131=quotereqid|" + + "146=1|" // NoRelatedSym + + "55=ABC|65=CD|48=securityid|22=1|" // group + + "711=1|" // NoUnderlyings + + "311=underlyingsymbol|312=WI|309=underlyingsecurityid|305=1|" + + "10=999|").Replace('|', Message.SOH); var dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); @@ -931,9 +906,11 @@ public void issue95() // make sure repeating groups are not rearranged // 1 level deep - StringAssert.Contains(String.Join(Message.SOH, new string[] { "55=ABC", "65=CD", "48=securityid", "22=1" }), msg.ConstructString()); + StringAssert.Contains("55=ABC|65=CD|48=securityid|22=1|".Replace('|', Message.SOH), msg.ConstructString()); // 2 levels deep - StringAssert.Contains(String.Join(Message.SOH, new string[] { "311=underlyingsymbol", "312=WI", "309=underlyingsecurityid", "305=1" }), msg.ConstructString()); + StringAssert.Contains( + "311=underlyingsymbol|312=WI|309=underlyingsecurityid|305=1|".Replace('|', Message.SOH), + msg.ConstructString()); } [Test] diff --git a/UnitTests/SessionTest.cs b/UnitTests/SessionTest.cs index d40383b8a..4715986e9 100755 --- a/UnitTests/SessionTest.cs +++ b/UnitTests/SessionTest.cs @@ -9,40 +9,38 @@ namespace UnitTests { - class MockResponder : QuickFix.IResponder + internal class MockResponder : QuickFix.IResponder { + private readonly QuickFix.DefaultMessageFactory _messageFactory = new(); + private readonly QuickFix.IMessageFactory _defaultMsgFactory = new QuickFix.DefaultMessageFactory(); - #region Responder Members - QuickFix.DefaultMessageFactory messageFactory = new QuickFix.DefaultMessageFactory(); - - public Dictionary> msgLookup = new Dictionary>(); - public Queue dups = new Queue(); - - private QuickFix.IMessageFactory _defaultMsgFactory = new QuickFix.DefaultMessageFactory(); + public Dictionary> MsgLookup = new(); + public Queue Dups = new(); - public bool disconnected = false; + public bool Disconnected = false; + #region Responder Members public bool Send(string msgStr) { QuickFix.Fields.MsgType msgType = QuickFix.Message.IdentifyType(msgStr); string beginString = QuickFix.Message.ExtractBeginString(msgStr); - QuickFix.Message message = messageFactory.Create(beginString, msgType.Obj); + QuickFix.Message message = _messageFactory.Create(beginString, msgType.Value); QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); message.FromString(msgStr, false, dd, dd, _defaultMsgFactory); - if (!msgLookup.ContainsKey(msgType.getValue())) - msgLookup.Add(msgType.getValue(), new Queue()); + if (!MsgLookup.ContainsKey(msgType.Value)) + MsgLookup.Add(msgType.Value, new Queue()); - msgLookup[msgType.getValue()].Enqueue(message); + MsgLookup[msgType.Value].Enqueue(message); QuickFix.Fields.PossDupFlag possDup = new QuickFix.Fields.PossDupFlag(false); if (message.Header.IsSetField(possDup)) message.Header.GetField(possDup); - if (possDup.getValue() && msgType.getValue()!= QuickFix.Fields.MsgType.SEQUENCE_RESET) + if (possDup.Value && msgType.Value != QuickFix.Fields.MsgType.SEQUENCE_RESET) { - dups.Enqueue(message); + Dups.Enqueue(message); } return true; @@ -50,8 +48,9 @@ public bool Send(string msgStr) public void Disconnect() { - disconnected = true; + Disconnected = true; } + #endregion /// /// For debug use if needed @@ -59,10 +58,10 @@ public void Disconnect() public void DumpMsgLookup() { Console.WriteLine("Responder dump:"); - foreach (string key in msgLookup.Keys) + foreach (string key in MsgLookup.Keys) { - Console.WriteLine(String.Format(" {0}: count {1}", key, msgLookup[key].Count)); - foreach (QuickFix.Message m in msgLookup[key]) + Console.WriteLine($" {key}: count {MsgLookup[key].Count}"); + foreach (QuickFix.Message m in MsgLookup[key]) { Console.WriteLine(" - " + m.ConstructString()); } @@ -71,146 +70,116 @@ public void DumpMsgLookup() public int GetCount(string msgType) { - return msgLookup.ContainsKey(msgType) ? msgLookup[msgType].Count : 0; + return MsgLookup.TryGetValue(msgType, out var value) ? value.Count : 0; } - #endregion } class MockApplication : QuickFix.IApplication { - public System.Exception fromAppException = null; - public System.Exception fromAdminException = null; - public QuickFix.DoNotSend doNotSendException = null; + public Exception FromAppException = null; + public Exception FromAdminException = null; + public QuickFix.DoNotSend DoNotSendException = null; - #region Application Members + public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionId) { } - public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionID) + public void FromAdmin(QuickFix.Message message, QuickFix.SessionID sessionId) { - } - - public void FromAdmin(QuickFix.Message message, QuickFix.SessionID sessionID) - { - if (fromAdminException != null) - throw fromAdminException; + if (FromAdminException is not null) + throw FromAdminException; } public void ToApp(QuickFix.Message message, QuickFix.SessionID sessionId) { - if (doNotSendException != null) - throw doNotSendException; - + if (DoNotSendException is not null) + throw DoNotSendException; } - public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionID) + public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionId) { - if (fromAppException != null) - throw fromAppException; + if (FromAppException is not null) + throw FromAppException; } - public void OnCreate(QuickFix.SessionID sessionID) - { - - } + public void OnCreate(QuickFix.SessionID sessionId) { } - public void OnLogout(QuickFix.SessionID sessionID) + public void OnLogout(QuickFix.SessionID sessionId) { throw new NotImplementedException(); } - public void OnLogon(QuickFix.SessionID sessionID) - { - } - #endregion + public void OnLogon(QuickFix.SessionID sessionId) { } } class MockApplicationExt : QuickFix.IApplicationExt { - public HashSet InterceptedMessageTypes = new HashSet(); + public HashSet InterceptedMessageTypes = new(); - #region Application Members + public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionId) { } - public void ToAdmin(QuickFix.Message message, QuickFix.SessionID sessionID) - { - } + public void FromAdmin(QuickFix.Message message, QuickFix.SessionID sessionId) { } - public void FromAdmin(QuickFix.Message message, QuickFix.SessionID sessionID) - { - } - - public void ToApp(QuickFix.Message message, QuickFix.SessionID sessionId) - { - } + public void ToApp(QuickFix.Message message, QuickFix.SessionID sessionId) { } - public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionID) - { - } + public void FromApp(QuickFix.Message message, QuickFix.SessionID sessionId) { } - public void OnCreate(QuickFix.SessionID sessionID) - { - } + public void OnCreate(QuickFix.SessionID sessionId) { } - public void OnLogout(QuickFix.SessionID sessionID) - { - } + public void OnLogout(QuickFix.SessionID sessionId) { } - public void OnLogon(QuickFix.SessionID sessionID) - { - } + public void OnLogon(QuickFix.SessionID sessionId) { } - public void FromEarlyIntercept(QuickFix.Message message, QuickFix.SessionID sessionID) + public void FromEarlyIntercept(QuickFix.Message message, QuickFix.SessionID sessionId) { InterceptedMessageTypes.Add(message.Header.GetString(QuickFix.Fields.Tags.MsgType)); } - #endregion - } [TestFixture] public class SessionTest { - MockResponder responder = null; - - QuickFix.SessionID sessionID = null; - QuickFix.SessionSettings settings = null; - MockApplication application = null; - QuickFix.Session session = null; - QuickFix.Session session2 = null; - QuickFix.SettingsDictionary config = null; - SeqNumType seqNum = 1; - Regex msRegex = new Regex(@"\.[\d]{1,3}$"); - Regex microsecondRegex = new Regex(@"\.[\d]{1,6}$"); + private MockResponder _responder = null; + + private QuickFix.SessionID _sessionId = null; + private QuickFix.SessionSettings _settings = null; + private MockApplication _application = null; + private QuickFix.Session _session = null; + private QuickFix.Session _session2 = null; + private QuickFix.SettingsDictionary _config = null; + private SeqNumType _seqNum = 1; + private readonly Regex _msRegex = new(@"\.[\d]{1,3}$"); + private readonly Regex _microsecondRegex = new(@"\.[\d]{1,6}$"); [SetUp] public void Setup() { - responder = new MockResponder(); - sessionID = new QuickFix.SessionID("FIX.4.2", "SENDER", "TARGET"); - application = new MockApplication(); - settings = new QuickFix.SessionSettings(); + _responder = new MockResponder(); + _sessionId = new QuickFix.SessionID("FIX.4.2", "SENDER", "TARGET"); + _application = new MockApplication(); + _settings = new QuickFix.SessionSettings(); - config = new QuickFix.SettingsDictionary(); - config.SetBool(QuickFix.SessionSettings.PERSIST_MESSAGES, false); - config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator"); - config.SetString(QuickFix.SessionSettings.START_TIME, "00:00:00"); - config.SetString(QuickFix.SessionSettings.END_TIME, "00:00:00"); - settings.Set(sessionID, config); + _config = new QuickFix.SettingsDictionary(); + _config.SetBool(QuickFix.SessionSettings.PERSIST_MESSAGES, false); + _config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator"); + _config.SetString(QuickFix.SessionSettings.START_TIME, "00:00:00"); + _config.SetString(QuickFix.SessionSettings.END_TIME, "00:00:00"); + _settings.Set(_sessionId, _config); var logFactory = new NullLogFactory(); // use QuickFix.ScreenLogFactory(settings) if you need to see output // acceptor - session = new QuickFix.Session(false, application, new MemoryStoreFactory(), sessionID, - new QuickFix.DataDictionaryProvider(),new QuickFix.SessionSchedule(config), 0, logFactory, new QuickFix.DefaultMessageFactory(), "blah"); - session.SetResponder(responder); - session.CheckLatency = false; + _session = new QuickFix.Session(false, _application, new MemoryStoreFactory(), _sessionId, + new QuickFix.DataDictionaryProvider(),new QuickFix.SessionSchedule(_config), 0, logFactory, new QuickFix.DefaultMessageFactory(), "blah"); + _session.SetResponder(_responder); + _session.CheckLatency = false; // initiator - session2 = new QuickFix.Session(true, application, new MemoryStoreFactory(), new QuickFix.SessionID("FIX.4.2", "OTHER_SENDER", "OTHER_TARGET"), - new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(config), 0, logFactory, new QuickFix.DefaultMessageFactory(), "blah"); - session2.SetResponder(responder); - session2.CheckLatency = false; + _session2 = new QuickFix.Session(true, _application, new MemoryStoreFactory(), new QuickFix.SessionID("FIX.4.2", "OTHER_SENDER", "OTHER_TARGET"), + new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(_config), 0, logFactory, new QuickFix.DefaultMessageFactory(), "blah"); + _session2.SetResponder(_responder); + _session2.CheckLatency = false; - seqNum = 1; + _seqNum = 1; } public void Logon() @@ -225,51 +194,51 @@ public void Logon40() private void SendLogon(QuickFix.Message msg) { - msg.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - msg.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); - msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++)); + msg.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + msg.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); + msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum++)); msg.Header.SetField(new QuickFix.Fields.SendingTime(System.DateTime.UtcNow)); msg.SetField(new QuickFix.Fields.HeartBtInt(1)); - session.Next(msg.ConstructString()); + _session.Next(msg.ConstructString()); } public bool SENT_SEQUENCE_RESET() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.SEQUENCE_RESET) && - responder.msgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.SEQUENCE_RESET) && + _responder.MsgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET].Count > 0; } public bool SENT_RESEND_REQUEST() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.RESEND_REQUEST) && - responder.msgLookup[QuickFix.Fields.MsgType.RESEND_REQUEST].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.RESEND_REQUEST) && + _responder.MsgLookup[QuickFix.Fields.MsgType.RESEND_REQUEST].Count > 0; } public bool RESENT() { - if (responder.dups.Count == 0) + if (_responder.Dups.Count == 0) return false; - responder.dups.Dequeue(); + _responder.Dups.Dequeue(); return true; } public bool SENT_REJECT() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT) && - responder.msgLookup[QuickFix.Fields.MsgType.REJECT].Count>0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT) && + _responder.MsgLookup[QuickFix.Fields.MsgType.REJECT].Count>0; } public bool SENT_HEART_BEAT() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.HEARTBEAT) && - responder.msgLookup[QuickFix.Fields.MsgType.HEARTBEAT].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.HEARTBEAT) && + _responder.MsgLookup[QuickFix.Fields.MsgType.HEARTBEAT].Count > 0; } public bool SENT_BUSINESS_REJECT() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT) && - responder.msgLookup[QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT) && + _responder.MsgLookup[QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT].Count > 0; } public bool SENT_BUSINESS_REJECT(int reason) @@ -277,34 +246,31 @@ public bool SENT_BUSINESS_REJECT(int reason) if (!SENT_BUSINESS_REJECT()) return false; - QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT].First(); + QuickFix.Message msg = _responder.MsgLookup[QuickFix.Fields.MsgType.BUSINESS_MESSAGE_REJECT].First(); if (!msg.IsSetField(QuickFix.Fields.Tags.BusinessRejectReason)) return false; QuickFix.Fields.BusinessRejectReason reasonField = new QuickFix.Fields.BusinessRejectReason(); msg.GetField(reasonField); - if (reasonField.getValue() != reason) - return false; - - return true; + return reasonField.Value == reason; } public bool SENT_LOGOUT() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.LOGOUT) && - responder.msgLookup[QuickFix.Fields.MsgType.LOGOUT].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.LOGOUT) && + _responder.MsgLookup[QuickFix.Fields.MsgType.LOGOUT].Count > 0; } public bool SENT_NOS() { - return responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.NEWORDERSINGLE) && - responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count > 0; + return _responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.NEWORDERSINGLE) && + _responder.MsgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count > 0; } public bool DISCONNECTED() { - return responder.disconnected; + return _responder.Disconnected; } public bool SENT_REJECT(int reason, int refTag) @@ -312,14 +278,14 @@ public bool SENT_REJECT(int reason, int refTag) if (!SENT_REJECT()) return false; - QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.REJECT].First(); + QuickFix.Message msg = _responder.MsgLookup[QuickFix.Fields.MsgType.REJECT].First(); if (!msg.IsSetField(QuickFix.Fields.Tags.SessionRejectReason)) return false; QuickFix.Fields.SessionRejectReason reasonField = new QuickFix.Fields.SessionRejectReason(); msg.GetField(reasonField); - if(reasonField.getValue() != reason) + if(reasonField.Value != reason) return false; if (!msg.IsSetField(QuickFix.Fields.Tags.RefTagID)) @@ -327,10 +293,7 @@ public bool SENT_REJECT(int reason, int refTag) QuickFix.Fields.RefTagID refTagField = new QuickFix.Fields.RefTagID(); msg.GetField(refTagField); - if (refTagField.getValue() != refTag) - return false; - - return true; + return refTagField.Value == refTag; } public void SendNOSMessage() @@ -343,11 +306,11 @@ public void SendNOSMessage() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); - order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++)); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum++)); - session.Next(order.ConstructString()); + _session.Next(order.ConstructString()); } public void SendResendRequest(SeqNumType begin, SeqNumType end) @@ -366,17 +329,17 @@ public void SendResendRequest40(SeqNumType begin, SeqNumType end) private void SendTheMessage(QuickFix.Message msg) { - msg.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - msg.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); - msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++)); + msg.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + msg.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); + msg.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum++)); - session.Next(msg.ConstructString()); + _session.Next(msg.ConstructString()); } [Test] public void ConditionalTagMissingReject() - { - application.fromAppException = new QuickFix.FieldNotFoundException(61); + { + _application.FromAppException = new QuickFix.FieldNotFoundException(61); Logon(); SendNOSMessage(); @@ -389,8 +352,8 @@ public void ConditionalTagMissingReject() [Test] public void IncorrectTagValueReject() { - application.fromAppException = new QuickFix.IncorrectTagValue(54); - + _application.FromAppException = new QuickFix.IncorrectTagValue(54); + Logon(); SendNOSMessage(); Assert.That(SENT_REJECT(QuickFix.Fields.SessionRejectReason.VALUE_IS_INCORRECT,54)); @@ -400,7 +363,7 @@ public void IncorrectTagValueReject() [Test] public void UnsupportedMessageReject() { - application.fromAppException = new QuickFix.UnsupportedMessageType(); + _application.FromAppException = new QuickFix.UnsupportedMessageType(); Logon(); SendNOSMessage(); @@ -410,7 +373,7 @@ public void UnsupportedMessageReject() [Test] public void LogonReject() { - application.fromAdminException = new QuickFix.RejectLogon("Failed Logon"); + _application.FromAdminException = new QuickFix.RejectLogon("Failed Logon"); Logon(); Assert.That(SENT_LOGOUT()); @@ -430,7 +393,7 @@ public void HeartBeatCheckAfterMessageProcess() [Test] public void NextResendRequestNoMessagePersist() { - session.PersistMessages = false; + _session.PersistMessages = false; Logon(); //seq 1 @@ -457,8 +420,8 @@ public void TestGapFillOnResend() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.TargetCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.SenderCompID)); SeqNumType[] gapStarts = new[] { 1UL, 5UL, 11UL }; // 1st gap from seq num 1 to 2 is just the Logon message SeqNumType[] gapEnds = new[] { 2UL, 8UL, 15UL }; @@ -467,35 +430,35 @@ public void TestGapFillOnResend() for (SeqNumType msgSeqNum = gapEnds[0]; msgSeqNum < gapStarts[1]; ++msgSeqNum) { order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum)); - session.Send(order); + _session.Send(order); ++orderCount; } //seq 4, next is 5 for (SeqNumType msgSeqNum = gapStarts[1]; msgSeqNum < gapEnds[1]; ++msgSeqNum) { - session.GenerateHeartbeat(); + _session.GenerateHeartbeat(); } //seq 7, next is 8 for (SeqNumType msgSeqNum = gapEnds[1]; msgSeqNum < gapStarts[2]; ++msgSeqNum) { order.Header.SetField(new QuickFix.Fields.MsgSeqNum(msgSeqNum)); - session.Send(order); + _session.Send(order); ++orderCount; } //seq 10, next is 11 for (SeqNumType msgSeqNum = gapStarts[2]; msgSeqNum < gapEnds[2]; ++msgSeqNum) { - session.GenerateHeartbeat(); + _session.GenerateHeartbeat(); } // seq 11 - 14 - responder.msgLookup.Clear(); + _responder.MsgLookup.Clear(); SendResendRequest(1, 100); - Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.NEWORDERSINGLE), orderCount); - Assert.AreEqual(responder.GetCount(QuickFix.Fields.MsgType.SEQUENCE_RESET), gapStarts.Length); + Assert.AreEqual(_responder.GetCount(QuickFix.Fields.MsgType.NEWORDERSINGLE), orderCount); + Assert.AreEqual(_responder.GetCount(QuickFix.Fields.MsgType.SEQUENCE_RESET), gapStarts.Length); int count = -1; - foreach (QuickFix.Message sequenceResestMsg in responder.msgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET]) + foreach (QuickFix.Message sequenceResestMsg in _responder.MsgLookup[QuickFix.Fields.MsgType.SEQUENCE_RESET]) { Assert.AreEqual(sequenceResestMsg.GetString(QuickFix.Fields.Tags.GapFillFlag), "Y"); Assert.AreEqual(sequenceResestMsg.Header.GetULong(QuickFix.Fields.Tags.MsgSeqNum), gapStarts[++count]); @@ -506,40 +469,40 @@ public void TestGapFillOnResend() [Test] public void TestResendSessionLevelReject() { - Assert.False(session.ResendSessionLevelRejects); // check for correct default - Logon(); + Assert.False(_session.ResendSessionLevelRejects); // check for correct default + Logon(); QuickFix.FIX42.Reject reject = new QuickFix.FIX42.Reject( new QuickFix.Fields.RefSeqNum(10)); - reject.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.TargetCompID)); - reject.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.SenderCompID)); - session.Send(reject); + reject.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.TargetCompID)); + reject.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.SenderCompID)); + _session.Send(reject); - responder.msgLookup.Clear(); - session.ResendSessionLevelRejects = true; + _responder.MsgLookup.Clear(); + _session.ResendSessionLevelRejects = true; SendResendRequest(1, 100); - Assert.That(responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); + Assert.That(_responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); - responder.msgLookup.Clear(); - session.ResendSessionLevelRejects = false; + _responder.MsgLookup.Clear(); + _session.ResendSessionLevelRejects = false; SendResendRequest(1, 100); - Assert.False(responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); + Assert.False(_responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); } public void AssertMsInTag(string msgType, int tag, bool shouldHaveMs) { - QuickFix.Message msg = responder.msgLookup[msgType].Last(); + QuickFix.Message msg = _responder.MsgLookup[msgType].Last(); string sendingTime = msg.Header.GetString(tag); - Match m = msRegex.Match(sendingTime); + Match m = _msRegex.Match(sendingTime); Assert.That(m.Success == shouldHaveMs); } public void AssertMicrosecondsInTag(string msgType, int tag, bool shouldHaveMicrosecond) { - QuickFix.Message msg = responder.msgLookup[msgType].Last(); + QuickFix.Message msg = _responder.MsgLookup[msgType].Last(); string sendingTime = msg.Header.GetString(tag); - Match m = microsecondRegex.Match(sendingTime); + Match m = _microsecondRegex.Match(sendingTime); Assert.That(m.Success == shouldHaveMicrosecond); } @@ -547,24 +510,24 @@ public void AssertMicrosecondsInTag(string msgType, int tag, bool shouldHaveMicr public void TestMillisecondsInSendingTimeStamp() { // MS in timestamp should default to Y - Assert.That(session.TimeStampPrecision == QuickFix.Fields.Converters.TimeStampPrecision.Millisecond ); + Assert.That(_session.TimeStampPrecision == QuickFix.Fields.Converters.TimeStampPrecision.Millisecond ); // Ms should show up Logon(); AssertMsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, true); - + // No ms - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; Logon(); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Count == 2); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.LOGON].Count == 2); AssertMsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, false); // Less than FIX42 - no ms in timestamp, even if you tell it to - sessionID = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); - session.SessionID = sessionID; - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; + _sessionId = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); + _session.SessionID = _sessionId; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; Logon40(); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Count == 3); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.LOGON].Count == 3); AssertMsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, false); } @@ -572,49 +535,49 @@ public void TestMillisecondsInSendingTimeStamp() public void TestMicrosecondsInSendingTimeStamp() { // Microseconds in timestamp - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; // Microseconds should show up Logon(); AssertMicrosecondsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, true); // Milliseconds in timestamp - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; Logon(); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Count == 2); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.LOGON].Count == 2); AssertMsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, true); // Less than FIX42 - no microseconds in timestamp, even if you tell it to - sessionID = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); - session.SessionID = sessionID; - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; + _sessionId = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); + _session.SessionID = _sessionId; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; Logon40(); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Count == 3); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.LOGON].Count == 3); AssertMicrosecondsInTag(QuickFix.Fields.MsgType.LOGON, QuickFix.Fields.Tags.SendingTime, false); } [Test] public void TestMillisecondsInOrigSendingTimeStamp() { - // MS in timestamp should default - Assert.That( session.TimeStampPrecision == QuickFix.Fields.Converters.TimeStampPrecision.Millisecond ); - + // MS in timestamp should default + Assert.That( _session.TimeStampPrecision == QuickFix.Fields.Converters.TimeStampPrecision.Millisecond ); + // Logon first Logon(); - + // Do a resend request SendResendRequest(0, 2); AssertMsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, true); // NO MS - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; SendResendRequest(0, 2); AssertMsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, false); // Less than FIX42 - no ms in timestamp, even if you tell it to - sessionID = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); - session.SessionID = sessionID; - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; + _sessionId = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); + _session.SessionID = _sessionId; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Millisecond; SendResendRequest40(0, 2); AssertMsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, false); } @@ -622,8 +585,8 @@ public void TestMillisecondsInOrigSendingTimeStamp() [Test] public void TestMicrosecondsInOrigSendingTimeStamp() { - // Microsecond in timestamp - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; + // Microsecond in timestamp + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; // Logon first Logon(); @@ -633,14 +596,14 @@ public void TestMicrosecondsInOrigSendingTimeStamp() AssertMicrosecondsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, true); // NO MS - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Second; SendResendRequest(0, 2); AssertMicrosecondsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, false); // Less than FIX42 - no ms in timestamp, even if you tell it to - sessionID = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); - session.SessionID = sessionID; - session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; + _sessionId = new QuickFix.SessionID(QuickFix.FixValues.BeginString.FIX40, "SENDER", "TARGET"); + _session.SessionID = _sessionId; + _session.TimeStampPrecision = QuickFix.Fields.Converters.TimeStampPrecision.Microsecond; SendResendRequest40(0, 2); AssertMicrosecondsInTag(QuickFix.Fields.MsgType.SEQUENCERESET, QuickFix.Fields.Tags.OrigSendingTime, false); } @@ -649,13 +612,13 @@ public void TestMicrosecondsInOrigSendingTimeStamp() public void TestLastMsgSeqNumProcessed() { // Disabled by default - Assert.That(!session.EnableLastMsgSeqNumProcessed); + Assert.That(!_session.EnableLastMsgSeqNumProcessed); - session.EnableLastMsgSeqNumProcessed = true; + _session.EnableLastMsgSeqNumProcessed = true; - // Logon + // Logon Logon(); - QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.LOGON].Last(); + QuickFix.Message msg = _responder.MsgLookup[QuickFix.Fields.MsgType.LOGON].Last(); SeqNumType lastSeqNumProcessed = msg.Header.GetULong(QuickFix.Fields.Tags.LastMsgSeqNumProcessed); Assert.That(lastSeqNumProcessed == 1); @@ -668,12 +631,12 @@ public void TestLastMsgSeqNumProcessed() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); - order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++)); - session.Send(order); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum++)); + _session.Send(order); - msg = responder.msgLookup[QuickFix.Fields.MsgType.NEW_ORDER_D].Last(); + msg = _responder.MsgLookup[QuickFix.Fields.MsgType.NEW_ORDER_D].Last(); lastSeqNumProcessed = msg.Header.GetULong(QuickFix.Fields.Tags.LastMsgSeqNumProcessed); Assert.That(lastSeqNumProcessed == 1); } @@ -682,10 +645,10 @@ public void TestLastMsgSeqNumProcessed() public void TestMaxMessagesInResendRequest() { // Default - Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(0)); + Assert.That(_session.MaxMessagesInResendRequest, Is.EqualTo(0)); - session.MaxMessagesInResendRequest = 2500; - // Logon + _session.MaxMessagesInResendRequest = 2500; + // Logon Logon(); // NOS @@ -697,53 +660,53 @@ public void TestMaxMessagesInResendRequest() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5005)); // This will generate resend requests - session.Verify(order, true, false); + _session.Verify(order, true, false); // 3 resend requests // 2->2501 // 2502->5001 // 5002->5005 - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); - QuickFix.Message msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); + QuickFix.Message msg = _responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2)); Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(2501)); // Jump forward to the end of the resend chunk with a fillgap reset message QuickFix.FIX42.SequenceReset reset = new QuickFix.FIX42.SequenceReset(); - reset.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - reset.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); + reset.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + reset.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); reset.SetField(new QuickFix.Fields.GapFillFlag(true)); reset.Header.SetField(new QuickFix.Fields.MsgSeqNum(2)); reset.SetField(new QuickFix.Fields.NewSeqNo(2501)); - session.Next(reset.ConstructString()); + _session.Next(reset.ConstructString()); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2501)); - session.Next(order.ConstructString()); + _session.Next(order.ConstructString()); // Should have triggered next resend (2502->5001), check this //Console.WriteLine(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); - msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); + msg = _responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(2502)); Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5001)); // Jump forward to the end of the resend chunk with a fillgap reset message reset.Header.SetField(new QuickFix.Fields.MsgSeqNum(2502)); reset.SetField(new QuickFix.Fields.NewSeqNo(5001)); - session.Next(reset.ConstructString()); + _session.Next(reset.ConstructString()); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5001)); - session.Next(order.ConstructString()); // Triggers next resend (5002->5005) + _session.Next(order.ConstructString()); // Triggers next resend (5002->5005) //Console.WriteLine(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); - msg = responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 1); + msg = _responder.MsgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Dequeue(); Assert.That(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(5002)); Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5004)); } @@ -752,10 +715,10 @@ public void TestMaxMessagesInResendRequest() public void TestIgnorePossDupInResendRequest() { // Default is false - Assert.That(session.IgnorePossDupResendRequests, Is.EqualTo(false)); + Assert.That(_session.IgnorePossDupResendRequests, Is.EqualTo(false)); - session.IgnorePossDupResendRequests = true; - // Logon + _session.IgnorePossDupResendRequests = true; + // Logon Logon(); // NOS @@ -767,13 +730,13 @@ public void TestIgnorePossDupInResendRequest() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); - order.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum++)); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum++)); // This will generate resend requests - session.Send(order); + _session.Send(order); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1); QuickFix.Message msg = new QuickFix.FIX42.ResendRequest( new QuickFix.Fields.BeginSeqNo(1), @@ -781,7 +744,7 @@ public void TestIgnorePossDupInResendRequest() msg.Header.SetField(new QuickFix.Fields.PossDupFlag(true)); SendTheMessage(msg); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.NEWORDERSINGLE].Count == 1); } [Test] @@ -791,33 +754,33 @@ public void TestDoesSessionExist() QuickFix.SessionID validSessionID = new QuickFix.SessionID("FIX.4.2", "SENDER", "TARGET"); Assert.That(QuickFix.Session.DoesSessionExist(invalidSessionID), Is.EqualTo(false)); - Assert.That(QuickFix.Session.DoesSessionExist(validSessionID), Is.EqualTo(true)); + Assert.That(QuickFix.Session.DoesSessionExist(validSessionID), Is.EqualTo(true)); } [Test] public void TestSettingNextTargetMsgSeqNum() { - session.NextTargetMsgSeqNum = 100; - Assert.That(session.NextTargetMsgSeqNum, Is.EqualTo(100)); + _session.NextTargetMsgSeqNum = 100; + Assert.That(_session.NextTargetMsgSeqNum, Is.EqualTo(100)); } [Test] public void TestSettingNextSenderMsgSeqNum() { - session.NextSenderMsgSeqNum = 200; - Assert.That(session.NextSenderMsgSeqNum, Is.EqualTo(200)); + _session.NextSenderMsgSeqNum = 200; + Assert.That(_session.NextSenderMsgSeqNum, Is.EqualTo(200)); } [Test] public void TestGettingIsInitiator() { - Assert.That(session2.IsInitiator, Is.EqualTo(true)); + Assert.That(_session2.IsInitiator, Is.EqualTo(true)); } [Test] public void TestGettingIsAcceptor() { - Assert.That(session2.IsAcceptor, Is.EqualTo(false)); + Assert.That(_session2.IsAcceptor, Is.EqualTo(false)); } [Test] @@ -826,13 +789,13 @@ public void TestMessageStoreAccessor() List messages = new List(); messages.Clear(); - session.MessageStore.Get(0, 100, messages); + _session.MessageStore.Get(0, 100, messages); Assert.That(messages.Count, Is.EqualTo(0)); Logon(); messages.Clear(); - session.MessageStore.Get(0, 100, messages); + _session.MessageStore.Get(0, 100, messages); Assert.That(messages.Count, Is.EqualTo(1)); // logon response } @@ -842,7 +805,7 @@ public void TestRequiresOrigSendingTime_Y() // Under default configuration, session should reject a ResendRequest that lacks OrigSendingTime unset // Check default is as expected - Assert.That(session.RequiresOrigSendingTime, Is.EqualTo(true)); + Assert.That(_session.RequiresOrigSendingTime, Is.EqualTo(true)); Logon(); @@ -850,20 +813,20 @@ public void TestRequiresOrigSendingTime_Y() sr.GapFillFlag = new QuickFix.Fields.GapFillFlag(true); sr.Header.SetField(new QuickFix.Fields.PossDupFlag(true)); - sr.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum--)); // so it triggers DoTargetTooLow code + sr.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum--)); // so it triggers DoTargetTooLow code SendTheMessage(sr); - Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.REJECT].Count == 1); - QuickFix.FIX42.Reject rej = responder.msgLookup[QuickFix.Fields.MsgType.REJECT].Peek() as QuickFix.FIX42.Reject; - Assert.That(rej.SessionRejectReason.getValue(), Is.EqualTo(QuickFix.Fields.SessionRejectReason.REQUIRED_TAG_MISSING)); + Assert.That(_responder.MsgLookup[QuickFix.Fields.MsgType.REJECT].Count == 1); + QuickFix.FIX42.Reject rej = _responder.MsgLookup[QuickFix.Fields.MsgType.REJECT].Peek() as QuickFix.FIX42.Reject; + Assert.That(rej.SessionRejectReason.Value, Is.EqualTo(QuickFix.Fields.SessionRejectReason.REQUIRED_TAG_MISSING)); } [Test] public void TestRequiresOrigSendingTime_N() { // Under OrigSendingTime=N, session will allow ResendRequest that lacks OrigSendingTime - session.RequiresOrigSendingTime = false; + _session.RequiresOrigSendingTime = false; Logon(); @@ -871,11 +834,11 @@ public void TestRequiresOrigSendingTime_N() sr.GapFillFlag = new QuickFix.Fields.GapFillFlag(true); sr.Header.SetField(new QuickFix.Fields.PossDupFlag(true)); - sr.Header.SetField(new QuickFix.Fields.MsgSeqNum(seqNum--)); // so it triggers DoTargetTooLow code + sr.Header.SetField(new QuickFix.Fields.MsgSeqNum(_seqNum--)); // so it triggers DoTargetTooLow code SendTheMessage(sr); - Assert.False(responder.msgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); + Assert.False(_responder.MsgLookup.ContainsKey(QuickFix.Fields.MsgType.REJECT)); } [Test] public void TestToAppDoNotSend() @@ -889,8 +852,8 @@ public void TestToAppDoNotSend() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - application.doNotSendException = new QuickFix.DoNotSend(); - session.Send(order); + _application.DoNotSendException = new QuickFix.DoNotSend(); + _session.Send(order); Assert.False(SENT_NOS()); } @@ -906,11 +869,11 @@ public void TestToAppResendDoNotSend() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - session.Send(order); + _session.Send(order); Assert.True(SENT_NOS()); - responder.msgLookup.Remove(QuickFix.Fields.MsgType.NEWORDERSINGLE); - application.doNotSendException = new QuickFix.DoNotSend(); + _responder.MsgLookup.Remove(QuickFix.Fields.MsgType.NEWORDERSINGLE); + _application.DoNotSendException = new QuickFix.DoNotSend(); SendResendRequest(1, 0); Assert.False(SENT_NOS()); @@ -921,10 +884,10 @@ public void TestToAppResendDoNotSend() public void TestApplicationExtension() { var mockApp = new MockApplicationExt(); - session = new QuickFix.Session(true, mockApp, new MemoryStoreFactory(), sessionID, - new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(config), 0, new NullLogFactory(), new QuickFix.DefaultMessageFactory(), "blah"); - session.SetResponder(responder); - session.CheckLatency = false; + _session = new QuickFix.Session(true, mockApp, new MemoryStoreFactory(), _sessionId, + new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(_config), 0, new NullLogFactory(), new QuickFix.DefaultMessageFactory(), "blah"); + _session.SetResponder(_responder); + _session.CheckLatency = false; Logon(); QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle( @@ -935,11 +898,11 @@ public void TestApplicationExtension() new QuickFix.Fields.TransactTime(), new QuickFix.Fields.OrdType(QuickFix.Fields.OrdType.LIMIT)); - order.Header.SetField(new QuickFix.Fields.TargetCompID(sessionID.SenderCompID)); - order.Header.SetField(new QuickFix.Fields.SenderCompID(sessionID.TargetCompID)); + order.Header.SetField(new QuickFix.Fields.TargetCompID(_sessionId.SenderCompID)); + order.Header.SetField(new QuickFix.Fields.SenderCompID(_sessionId.TargetCompID)); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2)); - session.Next(order.ConstructString()); + _session.Next(order.ConstructString()); Assert.That(mockApp.InterceptedMessageTypes.Count, Is.EqualTo(2)); Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.LOGON)); @@ -964,7 +927,7 @@ public void TestRequireLogon() [Test] public void TestResendRequestMsgSeqNumNotIgnoredWhenNoPersistance() { - session.PersistMessages = false; + _session.PersistMessages = false; Logon(); From 8d14aa60f1fd88c62286eac84558951445389458 Mon Sep 17 00:00:00 2001 From: Grant Birchmeier Date: Wed, 25 Sep 2024 14:47:21 -0500 Subject: [PATCH 2/2] delete "#nullable enable" from QuickFIX proj files --- QuickFIXn/AbstractInitiator.cs | 3 +-- QuickFIXn/AcceptorSocketDescriptor.cs | 1 - QuickFIXn/ClientHandlerThread.cs | 3 +-- QuickFIXn/DefaultMessageFactory.cs | 3 +-- QuickFIXn/Fields/Converters/DateTimeConverter.cs | 3 +-- QuickFIXn/Fields/IField.cs | 3 +-- QuickFIXn/HttpServer.cs | 3 +-- QuickFIXn/Logger/CompositeLog.cs | 3 +-- QuickFIXn/Logger/CompositeLogFactory.cs | 3 +-- QuickFIXn/Logger/FileLog.cs | 3 +-- QuickFIXn/Logger/FileLogFactory.cs | 4 +--- QuickFIXn/Logger/ILogFactory.cs | 4 +--- QuickFIXn/Logger/NonSessionLog.cs | 3 --- QuickFIXn/Logger/NullLogFactory.cs | 4 +--- QuickFIXn/Logger/ScreenLog.cs | 4 +--- QuickFIXn/Logger/ScreenLogFactory.cs | 4 +--- QuickFIXn/Message/FieldMap.cs | 3 +-- QuickFIXn/Message/FieldNotFoundException.cs | 3 +-- QuickFIXn/Message/Group.cs | 3 +-- QuickFIXn/Message/Header.cs | 2 -- QuickFIXn/Message/Message.cs | 3 +-- QuickFIXn/Message/Trailer.cs | 2 -- QuickFIXn/MessageBuilder.cs | 4 +--- QuickFIXn/Session.cs | 1 - QuickFIXn/SessionFactory.cs | 3 +-- QuickFIXn/SessionID.cs | 3 +-- QuickFIXn/SessionSchedule.cs | 3 +-- QuickFIXn/SessionState.cs | 1 - QuickFIXn/Settings.cs | 3 +-- QuickFIXn/SettingsDictionary.cs | 3 +-- QuickFIXn/SocketInitiatorThread.cs | 3 +-- QuickFIXn/SocketReader.cs | 3 +-- QuickFIXn/Store/FileStore.cs | 3 +-- QuickFIXn/Store/FileStoreFactory.cs | 4 +--- QuickFIXn/Store/MemoryStore.cs | 3 +-- QuickFIXn/ThreadedSocketAcceptor.cs | 3 +-- QuickFIXn/ThreadedSocketReactor.cs | 3 +-- QuickFIXn/Transport/SocketInitiator.cs | 3 +-- QuickFIXn/Transport/SslCertCache.cs | 1 - QuickFIXn/Transport/SslStreamFactory.cs | 1 - QuickFIXn/Transport/StreamFactory.cs | 3 +-- QuickFIXn/Util/StringUtil.cs | 1 - RELEASE_NOTES.md | 2 +- 43 files changed, 34 insertions(+), 87 deletions(-) diff --git a/QuickFIXn/AbstractInitiator.cs b/QuickFIXn/AbstractInitiator.cs index ecf9f924e..7222d43d1 100644 --- a/QuickFIXn/AbstractInitiator.cs +++ b/QuickFIXn/AbstractInitiator.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Threading; +using System.Threading; using System.Collections.Generic; using System; using QuickFix.Logger; diff --git a/QuickFIXn/AcceptorSocketDescriptor.cs b/QuickFIXn/AcceptorSocketDescriptor.cs index 47bf92810..2349b44d9 100644 --- a/QuickFIXn/AcceptorSocketDescriptor.cs +++ b/QuickFIXn/AcceptorSocketDescriptor.cs @@ -1,4 +1,3 @@ -#nullable enable using System.Collections.Generic; using System.Net; using QuickFix.Logger; diff --git a/QuickFIXn/ClientHandlerThread.cs b/QuickFIXn/ClientHandlerThread.cs index 042bfd4ed..323c339cb 100755 --- a/QuickFIXn/ClientHandlerThread.cs +++ b/QuickFIXn/ClientHandlerThread.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Net.Sockets; +using System.Net.Sockets; using System.Threading; using System; using QuickFix.Logger; diff --git a/QuickFIXn/DefaultMessageFactory.cs b/QuickFIXn/DefaultMessageFactory.cs index 720013ac6..58dbc073b 100644 --- a/QuickFIXn/DefaultMessageFactory.cs +++ b/QuickFIXn/DefaultMessageFactory.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/QuickFIXn/Fields/Converters/DateTimeConverter.cs b/QuickFIXn/Fields/Converters/DateTimeConverter.cs index 5bd9d6062..3b16d9d3f 100644 --- a/QuickFIXn/Fields/Converters/DateTimeConverter.cs +++ b/QuickFIXn/Fields/Converters/DateTimeConverter.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.Globalization; diff --git a/QuickFIXn/Fields/IField.cs b/QuickFIXn/Fields/IField.cs index ff39b4473..a2cbb880b 100644 --- a/QuickFIXn/Fields/IField.cs +++ b/QuickFIXn/Fields/IField.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; namespace QuickFix.Fields { diff --git a/QuickFIXn/HttpServer.cs b/QuickFIXn/HttpServer.cs index b4ff671be..4e1eb48c2 100644 --- a/QuickFIXn/HttpServer.cs +++ b/QuickFIXn/HttpServer.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/QuickFIXn/Logger/CompositeLog.cs b/QuickFIXn/Logger/CompositeLog.cs index 61722c144..f204fc9dc 100644 --- a/QuickFIXn/Logger/CompositeLog.cs +++ b/QuickFIXn/Logger/CompositeLog.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; namespace QuickFix.Logger; diff --git a/QuickFIXn/Logger/CompositeLogFactory.cs b/QuickFIXn/Logger/CompositeLogFactory.cs index 68180a805..700d8c0eb 100644 --- a/QuickFIXn/Logger/CompositeLogFactory.cs +++ b/QuickFIXn/Logger/CompositeLogFactory.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Linq; +using System.Linq; namespace QuickFix.Logger; diff --git a/QuickFIXn/Logger/FileLog.cs b/QuickFIXn/Logger/FileLog.cs index 65ebdaf93..2041ed650 100755 --- a/QuickFIXn/Logger/FileLog.cs +++ b/QuickFIXn/Logger/FileLog.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using QuickFix.Fields.Converters; using QuickFix.Util; diff --git a/QuickFIXn/Logger/FileLogFactory.cs b/QuickFIXn/Logger/FileLogFactory.cs index ecaed22f4..fc9bfc568 100755 --- a/QuickFIXn/Logger/FileLogFactory.cs +++ b/QuickFIXn/Logger/FileLogFactory.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Logger; +namespace QuickFix.Logger; /// /// Creates a message store that stores messages in a file diff --git a/QuickFIXn/Logger/ILogFactory.cs b/QuickFIXn/Logger/ILogFactory.cs index d5db1eec2..231f1d566 100755 --- a/QuickFIXn/Logger/ILogFactory.cs +++ b/QuickFIXn/Logger/ILogFactory.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Logger; +namespace QuickFix.Logger; /// /// Creates a log instance diff --git a/QuickFIXn/Logger/NonSessionLog.cs b/QuickFIXn/Logger/NonSessionLog.cs index 5e6953e22..3cc0d6bc9 100644 --- a/QuickFIXn/Logger/NonSessionLog.cs +++ b/QuickFIXn/Logger/NonSessionLog.cs @@ -1,6 +1,3 @@ -#nullable enable -using System; - namespace QuickFix.Logger; /// diff --git a/QuickFIXn/Logger/NullLogFactory.cs b/QuickFIXn/Logger/NullLogFactory.cs index 5649b3ed0..1b0e74f97 100644 --- a/QuickFIXn/Logger/NullLogFactory.cs +++ b/QuickFIXn/Logger/NullLogFactory.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Logger; +namespace QuickFix.Logger; public class NullLogFactory : ILogFactory { diff --git a/QuickFIXn/Logger/ScreenLog.cs b/QuickFIXn/Logger/ScreenLog.cs index 8996eebc5..dd44516fc 100755 --- a/QuickFIXn/Logger/ScreenLog.cs +++ b/QuickFIXn/Logger/ScreenLog.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Logger; +namespace QuickFix.Logger; /// /// FIXME - needs to log sessionIDs, timestamps, etc. diff --git a/QuickFIXn/Logger/ScreenLogFactory.cs b/QuickFIXn/Logger/ScreenLogFactory.cs index cd67bd7e2..2e426ac9c 100755 --- a/QuickFIXn/Logger/ScreenLogFactory.cs +++ b/QuickFIXn/Logger/ScreenLogFactory.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Logger; +namespace QuickFix.Logger; public class ScreenLogFactory : ILogFactory { diff --git a/QuickFIXn/Message/FieldMap.cs b/QuickFIXn/Message/FieldMap.cs index 7a23807da..c544affd8 100644 --- a/QuickFIXn/Message/FieldMap.cs +++ b/QuickFIXn/Message/FieldMap.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/QuickFIXn/Message/FieldNotFoundException.cs b/QuickFIXn/Message/FieldNotFoundException.cs index 5e653654c..1376214dc 100644 --- a/QuickFIXn/Message/FieldNotFoundException.cs +++ b/QuickFIXn/Message/FieldNotFoundException.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; namespace QuickFix { diff --git a/QuickFIXn/Message/Group.cs b/QuickFIXn/Message/Group.cs index 3e7387ed7..a5bb145ec 100644 --- a/QuickFIXn/Message/Group.cs +++ b/QuickFIXn/Message/Group.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Text; namespace QuickFix diff --git a/QuickFIXn/Message/Header.cs b/QuickFIXn/Message/Header.cs index 5df0661f8..7dc916db9 100644 --- a/QuickFIXn/Message/Header.cs +++ b/QuickFIXn/Message/Header.cs @@ -1,5 +1,3 @@ -#nullable enable -using System; using System.Text; using QuickFix.Fields; diff --git a/QuickFIXn/Message/Message.cs b/QuickFIXn/Message/Message.cs index f978f0b11..e6435db8e 100644 --- a/QuickFIXn/Message/Message.cs +++ b/QuickFIXn/Message/Message.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Text; using QuickFix.Fields; using System.Text.RegularExpressions; diff --git a/QuickFIXn/Message/Trailer.cs b/QuickFIXn/Message/Trailer.cs index d4fadfb6f..25a177b4d 100644 --- a/QuickFIXn/Message/Trailer.cs +++ b/QuickFIXn/Message/Trailer.cs @@ -1,5 +1,3 @@ -#nullable enable -using System; using System.Text; using QuickFix.Fields; diff --git a/QuickFIXn/MessageBuilder.cs b/QuickFIXn/MessageBuilder.cs index 49eb3fbbe..deebf8e41 100644 --- a/QuickFIXn/MessageBuilder.cs +++ b/QuickFIXn/MessageBuilder.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix +namespace QuickFix { internal class MessageBuilder { diff --git a/QuickFIXn/Session.cs b/QuickFIXn/Session.cs index 3fd0c4ff2..d4e0c1a85 100755 --- a/QuickFIXn/Session.cs +++ b/QuickFIXn/Session.cs @@ -1,4 +1,3 @@ -#nullable enable using System; using System.Collections.Generic; using System.Threading; diff --git a/QuickFIXn/SessionFactory.cs b/QuickFIXn/SessionFactory.cs index c6650796b..867aeb170 100755 --- a/QuickFIXn/SessionFactory.cs +++ b/QuickFIXn/SessionFactory.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using QuickFix.Logger; using QuickFix.Store; diff --git a/QuickFIXn/SessionID.cs b/QuickFIXn/SessionID.cs index e6f2198f1..c85b07ca2 100755 --- a/QuickFIXn/SessionID.cs +++ b/QuickFIXn/SessionID.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; namespace QuickFix { diff --git a/QuickFIXn/SessionSchedule.cs b/QuickFIXn/SessionSchedule.cs index b869b63b6..e4a990bda 100755 --- a/QuickFIXn/SessionSchedule.cs +++ b/QuickFIXn/SessionSchedule.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; namespace QuickFix diff --git a/QuickFIXn/SessionState.cs b/QuickFIXn/SessionState.cs index f34b80c44..76206f8e6 100755 --- a/QuickFIXn/SessionState.cs +++ b/QuickFIXn/SessionState.cs @@ -1,4 +1,3 @@ -#nullable enable using System; using System.Collections.Generic; using QuickFix.Logger; diff --git a/QuickFIXn/Settings.cs b/QuickFIXn/Settings.cs index eeaf2878b..85a11ab36 100755 --- a/QuickFIXn/Settings.cs +++ b/QuickFIXn/Settings.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Collections.Generic; +using System.Collections.Generic; namespace QuickFix { diff --git a/QuickFIXn/SettingsDictionary.cs b/QuickFIXn/SettingsDictionary.cs index b5b0365d2..ed1af225a 100755 --- a/QuickFIXn/SettingsDictionary.cs +++ b/QuickFIXn/SettingsDictionary.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.Linq; using QuickFix.Fields.Converters; diff --git a/QuickFIXn/SocketInitiatorThread.cs b/QuickFIXn/SocketInitiatorThread.cs index 96a73c6b3..db53b83ff 100755 --- a/QuickFIXn/SocketInitiatorThread.cs +++ b/QuickFIXn/SocketInitiatorThread.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Diagnostics; using System.IO; using System.Net; diff --git a/QuickFIXn/SocketReader.cs b/QuickFIXn/SocketReader.cs index 0cf97608f..32ea6a332 100755 --- a/QuickFIXn/SocketReader.cs +++ b/QuickFIXn/SocketReader.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Net.Sockets; +using System.Net.Sockets; using System.IO; using System; using System.Linq; diff --git a/QuickFIXn/Store/FileStore.cs b/QuickFIXn/Store/FileStore.cs index 4a9651dc6..770f11659 100755 --- a/QuickFIXn/Store/FileStore.cs +++ b/QuickFIXn/Store/FileStore.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.Text; using QuickFix.Util; diff --git a/QuickFIXn/Store/FileStoreFactory.cs b/QuickFIXn/Store/FileStoreFactory.cs index c3ecc945d..9f37b38e2 100755 --- a/QuickFIXn/Store/FileStoreFactory.cs +++ b/QuickFIXn/Store/FileStoreFactory.cs @@ -1,6 +1,4 @@ -#nullable enable - -namespace QuickFix.Store; +namespace QuickFix.Store; /// /// Creates a message store that stores messages in a file diff --git a/QuickFIXn/Store/MemoryStore.cs b/QuickFIXn/Store/MemoryStore.cs index 573f82db7..36826c76d 100755 --- a/QuickFIXn/Store/MemoryStore.cs +++ b/QuickFIXn/Store/MemoryStore.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; namespace QuickFix.Store; diff --git a/QuickFIXn/ThreadedSocketAcceptor.cs b/QuickFIXn/ThreadedSocketAcceptor.cs index 7e16e5a65..c57ce7950 100755 --- a/QuickFIXn/ThreadedSocketAcceptor.cs +++ b/QuickFIXn/ThreadedSocketAcceptor.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Net; using System; diff --git a/QuickFIXn/ThreadedSocketReactor.cs b/QuickFIXn/ThreadedSocketReactor.cs index 1f17c816c..ac7e5b103 100755 --- a/QuickFIXn/ThreadedSocketReactor.cs +++ b/QuickFIXn/ThreadedSocketReactor.cs @@ -1,5 +1,4 @@ -#nullable enable -using System.Collections.Generic; +using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Threading; diff --git a/QuickFIXn/Transport/SocketInitiator.cs b/QuickFIXn/Transport/SocketInitiator.cs index 4fed0e3b7..30984e86b 100644 --- a/QuickFIXn/Transport/SocketInitiator.cs +++ b/QuickFIXn/Transport/SocketInitiator.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/QuickFIXn/Transport/SslCertCache.cs b/QuickFIXn/Transport/SslCertCache.cs index 7eba7c122..3a13b0bbb 100644 --- a/QuickFIXn/Transport/SslCertCache.cs +++ b/QuickFIXn/Transport/SslCertCache.cs @@ -1,4 +1,3 @@ -#nullable enable using System; using System.Collections.Generic; using System.IO; diff --git a/QuickFIXn/Transport/SslStreamFactory.cs b/QuickFIXn/Transport/SslStreamFactory.cs index d4a784360..b5c5e9d64 100644 --- a/QuickFIXn/Transport/SslStreamFactory.cs +++ b/QuickFIXn/Transport/SslStreamFactory.cs @@ -1,4 +1,3 @@ -#nullable enable using System; using System.Diagnostics; using System.IO; diff --git a/QuickFIXn/Transport/StreamFactory.cs b/QuickFIXn/Transport/StreamFactory.cs index edb23ef2e..66117a7d0 100644 --- a/QuickFIXn/Transport/StreamFactory.cs +++ b/QuickFIXn/Transport/StreamFactory.cs @@ -1,5 +1,4 @@ -#nullable enable -using System; +using System; using System.IO; using System.Linq; using System.Net; diff --git a/QuickFIXn/Util/StringUtil.cs b/QuickFIXn/Util/StringUtil.cs index 7df33d047..333f1745c 100644 --- a/QuickFIXn/Util/StringUtil.cs +++ b/QuickFIXn/Util/StringUtil.cs @@ -1,4 +1,3 @@ -#nullable enable using System.Runtime.InteropServices; namespace QuickFix.Util diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e98e31203..10b98bbb9 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -35,7 +35,7 @@ What's New finishes loading all the dlls (gbirchmeier, with thanks to diagnosis by Brian Leach aka baffled) (Note: this may be the cause of spurious "incorrect BeginString" issues that have been observed) * #877 - throw an exception if Message.ToJSON(dd=null,convertEnumsToDescriptions=true) is called (gbirchmeier) -* #TBD - cleanup/nullable-ize IField-derived classes (gbirchmeier) +* #888 - cleanup/nullable-ize IField-derived classes (gbirchmeier) * deprecate lower-case-starting function names (renamed to upper-case-starting) * deprecate Field.Obj (renamed to Value) * deprecate Field.getValue/setValue (just use Value getter/setter)