Beispiel #1
0
        public void GenerateRequest_LoginMessage()
        {
            //configuration setup
            string currentID;

            using (var IDGEN = IdGenerator.GetIDGenerator())
            {
                currentID = Convert.ToString(Convert.ToInt32(IDGEN.CurrentID) + 1);
            }

            Nol3ConfigurationManager.SaveConfiguration(new Tools.Model.Nol3Configuration
            {
                ID       = Convert.ToInt32(currentID) - 1,
                Login    = "******",
                Password = "******"
            });

            string result   = FIXMLManager.GenerateUserLoginRequest();
            string expected = String.Format(@"<FIXML v=""5.0"" r=""20080317"" s=""20080314""><UserReq UserReqID=""{0}"" UserReqTyp=""1"" Username=""BOS"" Password=""BOS"" /></FIXML>", currentID);
            var    sb       = new StringBuilder();

            sb.AppendLine(String.Format("RESULT     : {0}", result));
            sb.AppendLine(String.Format("EXPECTED: {0}", expected));
            TestContext.WriteLine(sb.ToString());
            Assert.That(result, Is.EqualTo(expected));
        }
        public void UserStatusCanBecheckedAfterLogin()
        {
            string currentID;

            //prepare config
            using (var IDGen = IdGenerator.GetIDGenerator())
            {
                currentID = IDGen.CurrentID;

                Nol3ConfigurationManager.SaveConfiguration(new Tools.Model.Nol3Configuration
                {
                    ID       = Convert.ToInt32(IDGen.ID),
                    Login    = "******",
                    Password = "******"
                });
            }
            string response;

            using (var client =
                       Nol3.SendRequestSynch(
                           new Nol3Request(
                               FIXMLManager.GenerateUserLoginRequest()
                               )))
            {
                response = Nol3.ReciveResponse(client);
            }

            using (var client =
                       Nol3.SendRequestSynch(
                           new Nol3Request(
                               FIXMLManager.GenerateUserStatusRequest()
                               )))
            {
                response = Nol3.ReciveResponse(client);
            }

            //cleanup - logout
            using (var client = Nol3.SendRequestSynch(new Nol3Request(
                                                          FIXMLManager.GenerateUserLogoutRequest()
                                                          )))
            {
            }

            var userResponseObject = FIXMLManager.ParseUserResponseMessege(response);

            Assert.That(userResponseObject, Is.TypeOf <UserResponse>());
            Assert.That(userResponseObject.Username, Is.EqualTo("BOS"));
            Assert.That(userResponseObject.UserStatus, Is.EqualTo(UserStatus.LoggedIn));
            Assert.That(userResponseObject.MarketDepth, Is.EqualTo(1));
        }
Beispiel #3
0
        public void LoginNol3()
        {
            string responseMessage;

            using (var socket = _nol3Connector.SendRequestSynch(new Nol3Request(FIXMLManager.GenerateUserLoginRequest())))
            {
                responseMessage = _nol3Connector.ReciveResponse(socket);
                MessageParserToEventsAsync(responseMessage).Wait();
            }
            if (FIXMLManager.ParseUserResponseMessege(responseMessage)
                .UserStatus == UserStatus.LoggedIn)
            {
                //TODO : probably memeory leek from Socket
                AsyncPortListener(_nol3Connector.GetAsynchClinet(),
                                  _asyncPortListenerToken);
            }
        }