//public ChangeVerifyCodeData ChangeVerifyCode(ChangeVerifyCodeData changeVerifyCodeData)
        //{
        //    if (this.broker != null)
        //    {
        //        XusCvcCommand cvcCommand = new XusCvcCommand(this.broker, changeVerifyCodeData.OriginalVerifyCode, changeVerifyCodeData.NewVerifyCode, changeVerifyCodeData.ConfirmVerifyCode);
        //        cvcCommand.Execute();

        //        if (cvcCommand.Response.Status == ResponseStatus.Success)
        //            changeVerifyCodeData.SetLastOperation(true, cvcCommand.Response.InformationalMessage);
        //        else
        //            changeVerifyCodeData.SetLastOperation(false, cvcCommand.Response.InformationalMessage);
        //    }
        //    else
        //        changeVerifyCodeData.SetLastOperation(false, "No valid connection");

        //    return changeVerifyCodeData;
        //}

        public BrokerOperationResult ChangeVerifyCode(ChangeVerifyCode changeVerifyCodeData)
        {
            BrokerOperationResult returnResult = new BrokerOperationResult();

            if (this.broker != null)
            {
                XusCvcCommand cvcCommand = new XusCvcCommand(this.broker);

                // *** Make sure everything is upper case ***
                changeVerifyCodeData.OriginalVerifyCode = changeVerifyCodeData.OriginalVerifyCode.ToUpper().Trim();
                changeVerifyCodeData.NewVerifyCode      = changeVerifyCodeData.NewVerifyCode.ToUpper().Trim();
                changeVerifyCodeData.ConfirmVerifyCode  = changeVerifyCodeData.ConfirmVerifyCode.ToUpper().Trim();

                cvcCommand.AddCommandArguments(changeVerifyCodeData.OriginalVerifyCode, changeVerifyCodeData.NewVerifyCode, changeVerifyCodeData.ConfirmVerifyCode);

                RpcResponse response = cvcCommand.Execute();

                if (response.Status == RpcResponseStatus.Success)
                {
                    returnResult.SetResult(true, cvcCommand.Response.InformationalMessage);
                }
                else
                {
                    string message = string.IsNullOrWhiteSpace(cvcCommand.Response.InformationalMessage) ? "An unspecified error has occurred" : cvcCommand.Response.InformationalMessage;
                    returnResult.SetResult(false, message);
                }
            }
            else
            {
                returnResult.SetResult(false, "No valid connection");
            }

            return(returnResult);
        }
Beispiel #2
0
        public void TestMockChangeVerifyCode_BadData()
        {
            IRpcBroker broker = MockRpcBrokerFactory.GetXusChangeVerifyCodeBroker(false);

            XusCvcCommand cvcCommand = new XusCvcCommand(broker);

            RpcResponse response = cvcCommand.Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual(RpcResponseStatus.Fail, response.Status, response.InformationalMessage);
        }
        // TODO:...
        //[TestMethod]
        public void TestChangeVerifyCode()
        {
            string    accessCode;
            string    verifyCode;
            const int userIndex = 1;

            using (RpcBroker broker = GetConnectedBroker())
            {
                XusSignonSetupCommand setupCommand = new XusSignonSetupCommand(broker);

                RpcResponse response = setupCommand.Execute();

                if (response.Status == RpcResponseStatus.Success)
                {
                    accessCode = ValidAccessCodes[userIndex];
                    verifyCode = ValidVerifyCodes[userIndex];

                    XusAvCodeCommand avCommand = new XusAvCodeCommand(broker);

                    avCommand.AddCommandArguments(accessCode, verifyCode);

                    response = avCommand.Execute();

                    if ((response.Status == RpcResponseStatus.Success) || (avCommand.SignonResults.MustChangeVerifyCode))
                    {
                        // *** Automatically generated verify codes are in format "dss%####" ***
                        int numericPart;
                        if (int.TryParse(verifyCode.Substring(4), out numericPart))
                        {
                            numericPart += 1;

                            string newVCode = numericPart.ToString("DSS\\%000000000");

                            XusCvcCommand cvcCommand = new XusCvcCommand(broker);

                            cvcCommand.AddCommandArguments(verifyCode, newVCode, newVCode);

                            response = cvcCommand.Execute();

                            if (response.Status == RpcResponseStatus.Success)
                            {
                                string[] verifyCodes = (string[])ValidVerifyCodes.Clone();

                                verifyCodes[userIndex] = newVCode;
                                ValidVerifyCodes       = verifyCodes;
                            }                            // *** Check results ***
                            Assert.AreEqual(RpcResponseStatus.Success, response.Status);
                        }
                    }
                    else
                    {
                        Assert.Fail("XusAvCodeCommand failed");
                    }
                }
                else
                {
                    Assert.Fail("XusSignonSetupCommand failed");
                }

                broker.Disconnect();
            }
        }