public void TestApplicationExtension() { var mockApp = new MockApplicationExt(); session = new QuickFix.Session(mockApp, new QuickFix.MemoryStoreFactory(), sessionID, new QuickFix.DataDictionaryProvider(), new QuickFix.SessionSchedule(config), 0, new QuickFix.ScreenLogFactory(settings), new QuickFix.DefaultMessageFactory(), "blah"); session.SetResponder(responder); session.CheckLatency = false; Logon(); 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(2)); session.Next(order.ToString()); Assert.That(mockApp.InterceptedMessageTypes.Count, Is.EqualTo(2)); Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.LOGON)); Assert.True(mockApp.InterceptedMessageTypes.Contains(QuickFix.Fields.MsgType.NEWORDERSINGLE)); }
public void SendNOSMessage() { 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(seqNum++)); session.Next(order.ToString()); }
public void FromString_DoNotCorrectCounter() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); 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; n.FromString(s, true, dd, dd, _defaultMsgFactory); Assert.AreEqual("386=3", n.NoTradingSessions.toStringField()); StringAssert.Contains("386=3", n.ToString()); //don't correct it to 2, you bastard }
public void CheckGroupCountTest() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); string nul = Message.SOH; 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; n.FromString(s, true, dd, dd); //verify that FromString didn't correct the counter (if these fail, check if MessageTests::FromString_DoNotCorrectCounter() passes) Assert.AreEqual("386=3", n.NoTradingSessions.toStringField()); StringAssert.Contains("386=3", n.ToString()); Assert.Throws<QuickFix.RepeatingGroupCountMismatch>(delegate { dd.CheckGroupCount(n.NoTradingSessions, n, "D"); }); }
public void CheckGroupCountTest() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX42.NewOrderSingle n = new QuickFix.FIX42.NewOrderSingle(); string nul = Message.SOH; 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; n.FromString(s, true, dd, dd, _defaultMsgFactory); //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()); StringAssert.Contains("386=3", n.ToString()); Assert.Throws <QuickFix.RepeatingGroupCountMismatch>(delegate { dd.CheckGroupCount(n.NoTradingSessions, n, "D"); }); }
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)); }