public void ValidateDateAndTimeFields() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); 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; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); try { dd.Validate(message, beginString, msgType); } catch (QuickFix.TagException e) { Console.WriteLine(e.ToString()); Console.WriteLine(e.Field); throw; } }
public IList <FixMesageValidationErrorDescriptor> GetValidationErrors() { try { QuickFix.Message msg = new QuickFix.Message(); msg.FromString(_message, false, null, null); string beginString = msg.Header.GetField(QuickFix.Fields.Tags.BeginString); string msgType = msgType = msg.Header.GetField(QuickFix.Fields.Tags.MsgType); QuickFix.DataDictionary.DataDictionary dict = _dicSource.GetDictionaryForBeginString(beginString); dict.Validate(msg, beginString, msgType); return(null); } catch (Exception ex) { //TODO: create a validation method on fix dictionary that retuns a list of errors instead of just throwing on the first one FixMesageValidationErrorDescriptor descr = new FixMesageValidationErrorDescriptor(); descr.Message = ex.Message; return(new List <FixMesageValidationErrorDescriptor>(new FixMesageValidationErrorDescriptor[] { descr })); } }
public void ValidateWrongTypeInNestedRepeatingGroup() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=185", "35=J", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "70=AllocID", "71=0", "626=1", "857=0", "54=1", "55=sym", "53=1", "6=5.5","75=20110909-09:09:09.999", "73=1", // NoOrders "11=clordid", "756=1", // NoNested2PartyIDs "757=nested2partyid", "759=failboat", // supposed to be a int "10=48" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "J"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectDataFormat>()); }
public void ValidateGroupBeginsGroup() { // TODO: In a future version, change this so that // 1) generator will generate source for our test DD // 2) this test will use proper type-safe methods and not generics // Probably some or all of this would then move to MessageTests.cs QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadTestFIXSpec("group_begins_group"); string pipedStr = "8=FIX.9.9|9=167|35=magic|34=3|49=CLIENT1|52=20111012-22:15:55.474|56=EXECUTOR|" + "1111=mundane|5555=magicfield|6660=1|7770=2|7711=Hoppy|7712=brown|" + "7711=Floppy|7712=white|6661=abracadabra|10=48|"; // note: length and checksum might be garbage string msgStr = pipedStr.Replace("|", Message.SOH); string beginString = Message.ExtractBeginString(msgStr); Message msg = new Message(msgStr, dd, false); // true param means body-only, i.e. don't validate length/checksum dd.Validate(msg, true, beginString, "magic"); // Verify can retrieve one of the inner groups. // (Gotta use generic methods because code isn't generated for this DD) Group magicGroup = new Group(6660, 7770, new[] { 7770, 6661 }); msg.GetGroup(1, magicGroup); Group rabbitGroup = new Group(7770, 7711, new[] { 7711, 7722 }); magicGroup.GetGroup(2, rabbitGroup); Assert.AreEqual("abracadabra", magicGroup.GetString(6661)); Assert.AreEqual("Floppy", rabbitGroup.GetString(7711)); Assert.AreEqual("white", rabbitGroup.GetString(7712)); }
[Test] // Issue #282 investigation public void ValidateTagSpecifiedWithoutAValue() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.2", "9=65", "35=B", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "148=", "33=0", "10=188" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "B"; string beginString = "FIX.4.2"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd); dd.CheckFieldsHaveValues = true; Assert.Throws <QuickFix.NoTagValue>(delegate { dd.Validate(message, beginString, msgType); }); dd.CheckFieldsHaveValues = false; Assert.DoesNotThrow(delegate { dd.Validate(message, beginString, msgType); }); }
public void ValidateWithRepeatingGroupTest() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX42.MessageFactory f = new QuickFix.FIX42.MessageFactory(); string nul = Message.SOH; string msgStr = "8=FIX.4.2" + nul + "9=87" + nul + "35=B" + nul + "34=3" + nul + "49=CLIENT1" + nul + "52=20111012-22:15:55.474" + nul + "56=EXECUTOR" + nul + "148=AAAAAAA" + nul + "33=2" + nul + "58=L1" + nul + "58=L2" + nul + "10=016" + nul; QuickFix.Fields.MsgType msgType = Message.IdentifyType(msgStr); string beginString = Message.ExtractBeginString(msgStr); Message message = f.Create(beginString, msgType.Obj); message.FromString(msgStr, true, dd, dd, f); dd.Validate(message, beginString, msgType.Obj); }
public void ValidateTimeOnly_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); // intentionally invalid MDEntryTime (272/TimeOnly) string[] msgFields = { "8=FIX.4.4", "9=113", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "272=20111012", "273=20111012-22:15:30.444", "10=200" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectDataFormat>()); }
public void RequiredComponentRequiredField() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=76", "35=7", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "2=AdvId", "5=N", "4=B", "53=1", "10=138" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "7"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); var ex = Assert.Throws <QuickFix.RequiredTagMissing>(delegate { dd.Validate(message, beginString, msgType); }); Assert.AreEqual(55, ex.Field); }
[Test] // Issue #66 public void ValidateMultipleValueStringType_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=99", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "270=123.23", "271=2", "277=A 1", "10=196" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectTagValue>()); }
public void ValidateWrongType() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=120", "35=D", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "11=clordid", "55=sym", "54=1", "60=20110909-09:09:09.999", "40=1", "38=failboat",// should be a decimal "10=64" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "D"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectDataFormat>()); }
public void ValidateDateOnly_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); // intentionally invalid MDEntryDate (272/DateOnly) string[] msgFields = { "8=FIX.4.4", "9=117", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "272=20111012-22:15:30.444", "273=22:15:30.444", "10=175" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); // this should throw dd.Validate(message, beginString, msgType); }
public void ValidateDateTime_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); // intentionally invalid SendingTime (52/DateTime) string[] msgFields = { "8=FIX.4.4", "9=91", "35=W", "34=3", "49=sender", "52=20110909", "56=target", "55=sym", "268=1", "269=0", "272=20111012", "273=22:15:30.444", "10=51" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectDataFormat>()); }
[Test] // Issue #66 public void ValidateMultipleValueStringType() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary(); dd.LoadFIXSpec("FIX44"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=99", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "270=123.23", "271=2", "277=A B", "10=213" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd); dd.Validate(message, beginString, msgType); }
public void OptionalComponentRequiredField() { // issue #98 - message erroneously rejected because DD says that // component-required field is missing even though component is not present QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=77", "35=AD", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "568=tradereqid", "569=0", "10=109" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "AD"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); dd.Validate(message, beginString, msgType); }
public void ValidateWrongTypeInRepeatingGroup() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=111", "35=V", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "262=mdreqid", "263=0", "264=5", "267=1", // MDReqGrp "269=failboat", // should be a char "146=1", // InstrmtMDReqGrp "55=sym", "10=91" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "V"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf <QuickFix.IncorrectDataFormat>()); }
public void ValidateWrongTypeInNestedRepeatingGroup() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = {"8=FIX.4.4", "9=185", "35=J", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "70=AllocID", "71=0", "626=1", "857=0", "54=1", "55=sym", "53=1", "6=5.5", "75=20110909-09:09:09.999", "73=1", // NoOrders "11=clordid", "756=1", // NoNested2PartyIDs "757=nested2partyid", "759=failboat", // supposed to be a int "10=48"}; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "J"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); dd.Validate(message, beginString, msgType); }
public void ValidateWrongType() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = {"8=FIX.4.4", "9=120", "35=D", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "11=clordid", "55=sym", "54=1", "60=20110909-09:09:09.999", "40=1", "38=failboat", // should be a decimal "10=64"}; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "D"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); dd.Validate(message, beginString, msgType); }
public void ValidateTimeOnly_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); // intentionally invalid MDEntryTime (272/TimeOnly) string[] msgFields = { "8=FIX.4.4", "9=113", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "272=20111012", "273=20111012-22:15:30.444", "10=200" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); // this should throw dd.Validate(message, beginString, msgType); }
public void RequiredComponentRequiredField() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = { "8=FIX.4.4", "9=76", "35=7", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "2=AdvId", "5=N", "4=B", "53=1", "10=138" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "7"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); var ex = Assert.Throws<QuickFix.RequiredTagMissing>(delegate { dd.Validate(message, beginString, msgType); }); Assert.AreEqual(55, ex.Field); }
public void ValidateMultipleValueStringType_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary( "../../../spec/fix/FIX44.xml" ); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = {"8=FIX.4.4", "9=99", "35=W", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "55=sym", "268=1", "269=0", "270=123.23", "271=2", "277=A 1", "10=196"}; string msgStr = String.Join( Message.SOH, msgFields ) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create( beginString, msgType ); message.FromString( msgStr, true, dd, dd ); dd.Validate( message, beginString, msgType ); }
[Test] // Issue #282 investigation public void ValidateTagSpecifiedWithoutAValue() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = {"8=FIX.4.2", "9=65", "35=B", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "148=", "33=0", "10=188"}; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "B"; string beginString = "FIX.4.2"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd); dd.CheckFieldsHaveValues = true; Assert.Throws<QuickFix.NoTagValue>(delegate { dd.Validate(message, beginString, msgType); }); dd.CheckFieldsHaveValues = false; Assert.DoesNotThrow(delegate { dd.Validate(message, beginString, msgType); }); }
public void ValidateWrongTypeInRepeatingGroup() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); string[] msgFields = {"8=FIX.4.4", "9=111", "35=V", "34=3", "49=sender", "52=20110909-09:09:09.999", "56=target", "262=mdreqid", "263=0", "264=5", "267=1", // MDReqGrp "269=failboat", // should be a char "146=1", // InstrmtMDReqGrp "55=sym", "10=91"}; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "V"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); dd.Validate(message, beginString, msgType); }
public void ValidateWithRepeatingGroupTest() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX42.xml"); QuickFix.FIX42.MessageFactory f = new QuickFix.FIX42.MessageFactory(); string nul = Message.SOH; string msgStr = "8=FIX.4.2" + nul + "9=87" + nul + "35=B" + nul + "34=3" + nul + "49=CLIENT1" + nul + "52=20111012-22:15:55.474" + nul + "56=EXECUTOR" + nul + "148=AAAAAAA" + nul + "33=2" + nul + "58=L1" + nul + "58=L2" + nul + "10=016" + nul; QuickFix.Fields.MsgType msgType = Message.IdentifyType(msgStr); string beginString = Message.ExtractBeginString(msgStr); Message message = f.Create(beginString, msgType.Obj); message.FromString( msgStr, true, dd, dd); // Session.Next(message) dd.Validate(message, beginString, msgType.Obj); }
public void ValidateDateTime_Invalid() { QuickFix.DataDictionary.DataDictionary dd = new QuickFix.DataDictionary.DataDictionary("../../../spec/fix/FIX44.xml"); QuickFix.FIX44.MessageFactory f = new QuickFix.FIX44.MessageFactory(); // intentionally invalid SendingTime (52/DateTime) string[] msgFields = { "8=FIX.4.4", "9=91", "35=W", "34=3", "49=sender", "52=20110909", "56=target", "55=sym", "268=1", "269=0", "272=20111012", "273=22:15:30.444", "10=51" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; string msgType = "W"; string beginString = "FIX.4.4"; Message message = f.Create(beginString, msgType); message.FromString(msgStr, true, dd, dd, f); Assert.That(() => dd.Validate(message, beginString, msgType), Throws.TypeOf<QuickFix.IncorrectDataFormat>()); }