public void ShouldCreateCorrectStates()
        {
            String      infoAsString = "[123][ES0927465][][][][][][][][][][][][PAID]";
            PaymentInfo info         = PaymentInfo.ValueOf(infoAsString);

            Assert.AreEqual(State.PAID, info.State);
            Assert.AreEqual(infoAsString, info.ToString());

            infoAsString = "[123][ES0927465][][][][][][][][][][][][IDLE]";
            info         = PaymentInfo.ValueOf(infoAsString);
            Assert.AreEqual(State.IDLE, info.State);
            Assert.AreEqual(infoAsString, info.ToString());

            infoAsString = "[123][ES0927465][][][][][][][][][][][][IN_PROGRESS]";
            info         = PaymentInfo.ValueOf(infoAsString);
            Assert.AreEqual(State.IN_PROGRESS, info.State);
            Assert.AreEqual(infoAsString, info.ToString());

            infoAsString = "[123][ES0927465][][][][][][][][][][][][IN_PROGRESS_CONFIRM]";
            info         = PaymentInfo.ValueOf(infoAsString);
            Assert.AreEqual(State.IN_PROGRESS_CONFIRM, info.State);
            Assert.AreEqual(infoAsString, info.ToString());

            infoAsString = "[123][ES0927465][][][][][][][][][][][][INVALID]";
            info         = PaymentInfo.ValueOf(infoAsString);
            Assert.AreEqual(State.INVALID, info.State);
            Assert.AreEqual(infoAsString, info.ToString());
        }
        public void ShouldCreateStringFromNotFullPaymentInfo()
        {
            PaymentInfo info = new PaymentInfo();

            info.AmountToPay   = "11,24";
            info.BankAccountNo = "123456778900";
            info.BillerName    = "Biller Name";
            info.Currency      = "PLN";
            info.DueDate       = "13.10.2009";
            info.Id            = "200566";
            info.PostalCode    = "80-111";
            info.Title         = "SomeTitle";

            Assert.AreEqual("[200566][PL123456778900][][11,24][][SomeTitle][]"
                            + "[80-111][][Biller Name][13.10.2009][PLN][][INVALID]", info.ToString());

            PaymentInfo newOne = PaymentInfo.ValueOf(info.ToString());

            Assert.AreEqual("", newOne.Street);
            Assert.AreEqual("", newOne.City);
            Assert.AreEqual(newOne.ToString(), info.ToString());
            Assert.AreEqual(State.INVALID, newOne.State);
            Assert.IsFalse(newOne.IsDefinedTransfer);
            Assert.IsFalse(info.IsDefinedTransfer);
        }
示例#3
0
        /// <summary>
        /// Goes to the defined tansfer page.
        /// </summary>
        /// <param name="request">payment request</param>
        /// <param name="count">number of matching defined transfers (ones with the same name)</param>
        /// <param name="transferLink">transfer link element to click</param>
        private void GoToDefinedTransferPage(PaymentRequest request, int count, IHTMLElement transferLink)
        {
            PaymentInfo info = request.PaymentInfo;

            if (count > 0)
            {
                // more than one defined transfer with the provided name
                if (count > 1)
                {
                    String msg = String.Format(Resources.InteligoMoreThanOneDefinedTransfer, info.DefinedTransferName);
                    Util.ShowInfoMessage(msg);
                }
                transferLink.click();
            }
            else
            {
                // no defined transfer with the provided name
                String question = String.Format(Resources.InteligoNoDefinedTransfer, info.DefinedTransferName);

                if (Util.ShowYesNoQuestion(null, question) == true)
                {
                    info.DefinedTransferName = "";
                    Application.UserAppDataRegistry.SetValue(Util.CURRENT_PAYMENT, info.ToString());
                    GoToTransferPage(request);
                }
                else
                {
                    info.State = State.INVALID;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Marks given payment info as paid.
        /// </summary>
        /// <param name="info">payment info</param>
        /// <param name="sendMessage">if true sends broadcast message to other tabs</param>
        private void MarkAsPaid(PaymentInfo info, bool sendMessage)
        {
            String markAmount = info.AmountPaid.Replace(",", ".");

            if (info.AmountToPayInt <= info.AmountPaidInt)
            {
                markAmount = info.AmountToPay.Replace(",", ".");
            }
            Object[] args = new Object[] { info.Id,
                                           info.Amount.Replace(",", "."),
                                           info.AmountToPay.Replace(",", "."),
                                           info.AmountPaid.Replace(",", "."),
                                           "zap³acono z plugina" };

            webBrowser.Document.InvokeScript("markAsPaidToday", args);
            if (info.AmountPaidInt < info.AmountToPayInt && paymentInfoIndexMap.ContainsKey(info.Id))
            {
                paymentInfo[paymentInfoIndexMap[info.Id]].AmountToPayInt = info.AmountToPayInt - info.AmountPaidInt;
            }

            if (sendMessage == true)
            {
                Util.SetUpdatedPaymentInfo(info.ToString());
                SendMessageToAll(int.Parse(info.Id));
            }
        }
        public void ShouldCreatePaymentInfoFromString()
        {
            String infoAsString = "[098765][PL92837465][120,23][211,24][200.10][Title][\\[\\[Original\\]\\]\\[\\[Street\\]\\]\\[\\[Name\\]\\]]"
                                  + "[66111][\\[Some Very Long Name of The\\\\City\\]][Biller][13.10.2010][EUR][CASH_FLOW][INVALID]";
            PaymentInfo info = PaymentInfo.ValueOf(infoAsString);

            Assert.AreEqual("PL", info.CountryCode);
            Assert.AreEqual("098765", info.Id);
            Assert.AreEqual("92837465", info.BankAccountNo);
            Assert.AreEqual("120,23", info.Amount);
            Assert.AreEqual("211,24", info.AmountToPay);
            Assert.AreEqual(21124, info.AmountToPayInt);
            Assert.AreEqual("200.10", info.AmountPaid);
            Assert.AreEqual(20010, info.AmountPaidInt);
            Assert.AreEqual("Title", info.Title);
            Assert.AreEqual("[[Original]][[Street]][[Name]]", info.Street);
            Assert.AreEqual("66111", info.PostalCode);
            Assert.AreEqual("[Some Very Long Name of The\\City]", info.City);
            Assert.AreEqual("Biller", info.BillerName);
            Assert.AreEqual("EUR", info.Currency);
            Assert.AreEqual("CASH_FLOW", info.DefinedTransferName);
            Assert.AreEqual(State.INVALID, info.State);

            Assert.AreEqual(infoAsString, info.ToString());
        }
        public void ShouldIgnoreExecutionAsUserNotLogged()
        {
            AbstractProvider provider = new DummyNotLoggedProvider();

            PaymentInfo result = provider.Execute(new PaymentRequest(webBrowser, paymentInfo));

            Assert.AreEqual(result.ToString(), paymentInfo.ToString());
        }
        public void ShouldClonePaymentInfo()
        {
            PaymentInfo info  = BuildDefaultPaymentInfo();
            PaymentInfo clone = info.Clone();

            Assert.AreNotSame(info, clone);
            Assert.AreEqual(info.ToString(), clone.ToString());
        }
        public void ShouldCreateStringFromPaymentInfo()
        {
            PaymentInfo info = BuildDefaultPaymentInfo();

            Assert.AreEqual("[200566][DE123456778900][10,23][11,24][11.10][SomeTitle][\\[\\[Original\\]\\]\\[\\[Street\\]\\]\\[\\[Name\\]\\]]"
                            + "[80-111][\\[Some Very Long Name of The\\\\City\\]][Biller Name][13.10.2009][PLN][EMPTY][IN_PROGRESS]", info.ToString());

            PaymentInfo newOne = PaymentInfo.ValueOf(info.ToString());

            Assert.AreEqual(info.CountryCode, newOne.CountryCode);
            Assert.AreEqual(info.Street, newOne.Street);
            Assert.AreEqual(info.City, newOne.City);
            Assert.AreEqual(newOne.ToString(), info.ToString());
            Assert.AreEqual(State.IN_PROGRESS, info.State);
            Assert.AreEqual(State.IN_PROGRESS, newOne.State);
            Assert.IsTrue(newOne.IsDefinedTransfer);
        }
        public void ShouldCreateNullPaymentInfoFromString()
        {
            String      infoAsString = "[098765]";
            PaymentInfo info         = PaymentInfo.ValueOf(infoAsString);

            Assert.IsNull(info.Id);
            Assert.AreEqual("[][][][][][][][][][][][][][INVALID]", info.ToString());
            Assert.AreEqual(State.INVALID, info.State);
        }
示例#10
0
        /// <summary>
        /// Event invoked when user clicks "Pay" button in the sidebar.
        /// </summary>
        /// <param name="sender">pressed button's object</param>
        /// <param name="e">event arguments</param>
        private void PayButton_Click(object sender, System.EventArgs e)
        {
            try {
                Settings.Default.ReloadCount = 0;

                HtmlElement     element  = sender as HtmlElement;
                int             idx      = int.Parse(element.GetAttribute("index"));
                PaymentProvider provider = ProviderFactory.GetProvider(Util.GetProviderId(IEApp.LocationURL), true);

                paymentInfo[idx] = PaymentInfo.ValueOf(webBrowser.Document, paymentInfo[idx].Id);
                // leave original object unchanged
                PaymentInfo info = paymentInfo[idx].Clone();
                Util.SetCurrentPaymentInfo(info.ToString());
                provider.Execute(new PaymentRequest(IEApp, info, true));
                Util.SetCurrentPaymentInfo(info.ToString());
            } catch (Exception ex) {
                Util.ShowErrorMessage(ex.ToString());
            }
        }
        public void ShouldIgnoreExecutionAsMaxReloadReached()
        {
            AbstractProvider provider = new DummyLoggedProvider();

            Settings.Default.ReloadCount = Settings.Default.MaxReload + 1;

            PaymentInfo result = provider.Execute(new PaymentRequest(webBrowser, paymentInfo));

            Assert.AreEqual(result.ToString(), paymentInfo.ToString());
        }
        public void ShouldExecuteWithInvalidInfo()
        {
            AbstractProvider provider = new DummyLoggedProvider();

            paymentInfo.State = State.INVALID;
            PaymentInfo copy   = PaymentInfo.ValueOf(paymentInfo.ToString());
            PaymentInfo result = provider.Execute(new PaymentRequest(webBrowser, paymentInfo));

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
示例#13
0
        public void ShouldGoToTransferPageAfterIdleDefinedTransfer()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(false);
            PrepareGoToTransferPageMocks();

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldDoNothingAfterInProgress()
        {
            paymentInfo.State = State.IN_PROGRESS;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(true);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSelectDefinedTransferOnTransferPageAfterIdleSomeTransferAlreadySelected()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(true, false);
            PrepareDefinedTransfersPageMocks(true, 3);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldDoNothingAfterInProgressDefinedTransfer()
        {
            paymentInfo.State = State.IN_PROGRESS;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocksForDefinedTransfer("<span>" + paymentInfo.DefinedTransferName + "</span>");

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldPastePaymentInfoForDefinedTransfer()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(true);
            PreparePastePaymentInfoMocks();

            PaymentInfo result = provider.Execute(request);

            copy.State = State.IN_PROGRESS;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldDoNothingAfterInProgessConfirm()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareLoggedUserMocks();
            PrepareConfirmPageMocks(true, null, null, false);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStateAsInvalidOnTransferPageAfterNoDefinedTransferFound()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(false, false);
            PrepareDefinedTransfersPageMocks(true, 0);

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
示例#20
0
        public void ShouldGoToTransferPageOnPastePaymentInfoForNotSelectedAnyTransfer()
        {
            paymentInfo.DefinedTransferName = "";
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(true);
            PreparePastePaymentInfoMocks(false, true);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSelectDefinedTransferPage()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(false);
            PrepareDefinedTransferPageMocks(true);
            PrepareSelectDefinedTransfer(paymentInfo.DefinedTransferName.ToUpper(), true);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStatusAsPaidAfterInProgressConfirmForDefinedTransfer()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareIsConfirmationPageMocks("Twoja p³atnoœæ zostanie zrealizowana w dniu");

            PaymentInfo result = provider.Execute(request);

            copy.State = State.PAID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
示例#23
0
        public void ShouldSetPaymentStateUnchangedAfterInProgressConfirm()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareConfirmationPageMocks(false, null, null);
            PrepareReadyToPasteMocks(true);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStateAsInvalidAfterInProgressConfirm()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareInProgressConfirmMocks(null, true);

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStateAsPaidAfterInProgressConfirm()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareInProgressConfirmMocks("<p>Dyspozycja przelewu zosta³a przyjêta.</p>", false);

            PaymentInfo result = provider.Execute(request);

            copy.State = State.PAID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStatusAsInvalidAfterIdleDefinedTransferNotExists()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteFalseMocks();
            PrepareDefinedTransfersPageMocks(true);
            PrepareSelectDefinedTransferAndGoToTransferPage(0);

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStatusAsInvalidAfterInProgressConfirmForAnyTransfer()
        {
            paymentInfo.State = State.IN_PROGRESS_CONFIRM;
            paymentInfo.DefinedTransferName = "";
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareIsConfirmationPageMocks("");

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStateAsInvalidAfterInProgress()
        {
            paymentInfo.State = State.IN_PROGRESS;
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteFalseMocks();
            PrepareIsConfirmPageFalseMocks();

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSelectSupportedAccountAfterIdleForDefinedTransfer()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteFalseMocks();
            PrepareDefinedTransfersPageMocks(false);
            PrepareAccountsListPageMocks(true);
            PrepareSelectAccountAndGoToTransferPageMocks(1);

            PaymentInfo result = provider.Execute(request);

            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }
        public void ShouldSetPaymentStateAsInvalidForNotExistingDefinedTransfer()
        {
            PaymentInfo copy = PaymentInfo.ValueOf(paymentInfo.ToString());

            PrepareReadyToPasteMocks(false);
            PrepareDefinedTransferPageMocks(true);
            PrepareSelectDefinedTransfer(paymentInfo.DefinedTransferName + "123", false);

            PaymentInfo result = provider.Execute(request);

            copy.State = State.INVALID;
            Assert.AreNotSame(copy, result);
            Assert.AreEqual(copy.ToString(), result.ToString());
        }