public static int?GetNullIntFieldIfSet(QuickFix.Message message, int field) { if (message.IsSetField(field)) { return(message.GetInt(field)); } else { return(null); } }
public void TestMaxMessagesInResendRequest() { // Default Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(0)); session.MaxMessagesInResendRequest = 2500; // Logon Logon(); // NOS QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle( new QuickFix.Fields.ClOrdID("1"), new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER), new QuickFix.Fields.Symbol("IBM"), new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY), 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(5005)); // This will generate resend requests session.Verify(order, true, false); // 3 resend requests // 2->2501 // 2502->5001 // 5002->5005 Assert.That(responder.msgLookup[QuickFix.Fields.MsgType.RESENDREQUEST].Count == 3); 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)); 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)); 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)); }
public void TestMaxMessagesInResendRequest() { // Default Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(0)); session.MaxMessagesInResendRequest = 2500; // Logon Logon(); // NOS QuickFix.FIX42.NewOrderSingle order = new QuickFix.FIX42.NewOrderSingle( new QuickFix.Fields.ClOrdID("1"), new QuickFix.Fields.HandlInst(QuickFix.Fields.HandlInst.MANUAL_ORDER), new QuickFix.Fields.Symbol("IBM"), new QuickFix.Fields.Side(QuickFix.Fields.Side.BUY), 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(5005)); // This will generate resend requests 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(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.SetField(new QuickFix.Fields.GapFillFlag(true)); reset.Header.SetField(new QuickFix.Fields.MsgSeqNum(2)); reset.SetField(new QuickFix.Fields.NewSeqNo(2501)); session.Next(reset.ToString()); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(2501)); session.Next(order.ToString()); // 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(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.ToString()); order.Header.SetField(new QuickFix.Fields.MsgSeqNum(5001)); session.Next(order.ToString()); // 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(msg.GetInt(QuickFix.Fields.Tags.BeginSeqNo), Is.EqualTo(5002)); Assert.That(msg.GetInt(QuickFix.Fields.Tags.EndSeqNo), Is.EqualTo(5004)); }