public void TestRegister()
        {
            var mt = new MessageTemplate("Logon", new Field[0]);
            AbstractTemplateRegistry registry = new BasicTemplateRegistry {{1000, mt}};

            Assert.Contains(mt, registry.Templates);
            Assert.AreEqual(1000, registry.GetId("Logon"));
            Assert.AreEqual(1000, registry.GetId(mt));
            Assert.AreEqual(mt, registry[1000]);
            Assert.AreEqual(mt, registry["Logon"]);
        }
        public void TestDefine()
        {
            var mt = new MessageTemplate("Logon", new Field[0]);
            AbstractTemplateRegistry registry = new BasicTemplateRegistry();
            registry.Define(mt);

            //Assert.Contains(mt, registry.Templates);//dont know why it need to access when it is just defined *SM*
            Assert.AreEqual(-1, registry.GetId("Logon"));
            Assert.AreEqual(-1, registry.GetId(mt));
            Assert.AreEqual(null, registry[1000]);
            Assert.AreEqual(mt, registry["Logon"]);
        }
        public void NewSession(Session session)
        {
            //session.Listening = true;
            session.ErrorHandler = new TCPServer.FASTServer.ServerErrorHandler();
            session.MessageHandler = new FASTMessageListener();
            //register a template
            TemplateRegistry registry = new BasicTemplateRegistry();
            var template = new MessageTemplate("Arbitry",
               new Field[] {
                    new Scalar("1", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.I32, Operator.DELTA, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.I32, Operator.INCREMENT,
                        new IntegerValue(10), false),
                    new Scalar("4", FASTType.I32, Operator.INCREMENT,
                        ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.I32, Operator.CONSTANT,
                        new IntegerValue(1), false), /* NON-TRANSFERRABLE */
                new Scalar("6", FASTType.I32, Operator.DEFAULT,
                        new IntegerValue(2), false)
                });
            registry.Register(24, template);

            session.MessageInputStream.RegisterTemplate(24, template);
            //send that template
            session.SendTemplates(registry);

            while (true)
            {
                DateTime startTime = DateTime.Now;
                for (int i = 0; i < 64000; i++)
                {
                    //make a message
                    var message = new Message(template);
                    message.SetInteger(1, 109);
                    message.SetInteger(2, 29470);
                    message.SetInteger(3, 10);
                    message.SetInteger(4, 3);
                    message.SetInteger(5, 1);
                    message.SetInteger(6, 2);

                    //send it to client
                    session.MessageOutputStream.WriteMessage(message);
                }
                double seconds = (DateTime.Now - startTime).TotalSeconds;
                Console.WriteLine(seconds);
                Console.WriteLine("MSG/S:" + (64000 / seconds).ToString("0"));
            }
        }
        public void NewSession(Session session)
        {
            //session.IsListening = true;
            session.ErrorHandler = new FastServer.ServerErrorHandler();
            session.MessageHandler = new MessageListener();

            //register a template
            var template = new MessageTemplate(
                "Arbitry",
                new Field[]
                    {
                        new Scalar("1", FastType.I32, Operator.Copy, ScalarValue.Undefined, false),
                        new Scalar("2", FastType.I32, Operator.Delta, ScalarValue.Undefined, false),
                        new Scalar("3", FastType.I32, Operator.Increment, new IntegerValue(10), false),
                        new Scalar("4", FastType.I32, Operator.Increment, ScalarValue.Undefined, false),
                        new Scalar("5", FastType.I32, Operator.Constant, new IntegerValue(1), false),
                        /* NON-TRANSFERRABLE */
                        new Scalar("6", FastType.I32, Operator.Default, new IntegerValue(2), false)
                    });

            ITemplateRegistry registry = new BasicTemplateRegistry {{24, template}};
            session.MessageInputStream.RegisterTemplate(24, template);

            //send that template
            session.SendTemplates(registry);

            while (true)
            {
                DateTime startTime = DateTime.Now;
                for (int i = 0; i < 64000; i++)
                {
                    //make a message
                    var message = new Message(template);
                    message.SetInteger(1, 109);
                    message.SetInteger(2, 29470);
                    message.SetInteger(3, 10);
                    message.SetInteger(4, 3);
                    message.SetInteger(5, 1);
                    message.SetInteger(6, 2);

                    //send it to client
                    session.MessageOutputStream.WriteMessage(message);
                }
                double seconds = (DateTime.Now - startTime).TotalSeconds;
                Console.WriteLine(seconds);
                Console.WriteLine("MSG/S:" + (64000/seconds).ToString("0"));
            }
        }
        public void TestTemplateRef()
        {
            Message templateDef = _scp11.CreateTemplateDefinitionMessage(ObjectMother.BatchTemplate);
            Assert.AreEqual("Header", templateDef.GetSequence("Instructions")[0].GetGroup(0).GetString("Name"));
            Assert.AreEqual(SessionControlProtocol11.DynTempRefMessage,
                            templateDef.GetSequence("Instructions")[1].GetGroup(0)
                                .GetSequence("Instructions")[0].GetGroup(0));

            var registry = new BasicTemplateRegistry {{24, ObjectMother.HeaderTemplate}};
            Assert.AreEqual(ObjectMother.BatchTemplate, _scp11.CreateTemplateFromMessage(templateDef, registry));
        }