Пример #1
0
        public void DefaultFormatIsStandardFormat()
        {
            var accountNumber  = new AccountNumber(0, 12, "0100");
            var defaultFormat  = accountNumber.ToString(null, null);
            var standardFormat = accountNumber.ToString("S", null);

            Assert.Equal(standardFormat, defaultFormat);
        }
Пример #2
0
        public void DefaultFormatIsntFullFormat()
        {
            var accountNumber = new AccountNumber(0, 12, "0100");
            var defaultFormat = accountNumber.ToString(null, null);
            var fullFormat    = accountNumber.ToString("F", null);

            Assert.NotEqual(fullFormat, defaultFormat);
        }
Пример #3
0
 public InterBankTransfer(IAccount sender, AccountNumber receiverAccountNumber,
                          decimal amount, string operationTitle)
 {
     _operations = new List <BankOperation>
     {
         new OutgoingTransfer(sender, amount, operationTitle, receiverAccountNumber.ToString()),
         new TransferFee(sender, TransferFeeValue, receiverAccountNumber.ToString()),
         new RestTransfer(sender.AccountNumber, amount, operationTitle, receiverAccountNumber)
     };
     _sender = sender;
     _receiverAccountNumber = receiverAccountNumber;
     _operationTitle        = operationTitle;
     _amount        = amount;
     ResponseStatus = ResponseStatus.Success;
 }
Пример #4
0
        /// <summary>
        /// Currently only DE Supported
        /// </summary>
        /// <returns></returns>
        public string ToIBAN()
        {
            CountryCode = CountryCode.ToUpper();
            string strKontonummer = AccountNumber.ToString(CultureInfo.InvariantCulture);

            while (AccountNumber.Length != 10)
            {
                AccountNumber = "0" + strKontonummer;
            }


            string strLand1 = CountryCode.Substring(0, 1);
            string strLand2 = CountryCode.Substring(1, 1);

            int intLand1 = Strings.AscW(strLand1) - 55;
            int intLand2 = Strings.AscW(strLand2) - 55;

            string strBLZKonto = BankNumber.ToString(CultureInfo.InvariantCulture) +
                                 strKontonummer +
                                 intLand1.ToString(CultureInfo.InvariantCulture) +
                                 intLand2.ToString(CultureInfo.InvariantCulture) + "00";
            decimal decBLZKonto = Helper.Modulo(strBLZKonto, 97);


            string strPrüfsumme = (98 - decBLZKonto).ToString(CultureInfo.InvariantCulture);

            if (strPrüfsumme.Length == 1)
            {
                strPrüfsumme = "0" + strPrüfsumme;
            }
            return("DE" + strPrüfsumme + BankNumber.ToString(CultureInfo.InvariantCulture) + strKontonummer);
        }
Пример #5
0
        public void TestAccountNumberCreation(string expectedNumber, byte[] bytes)
        {
            AccountNumber number        = new AccountNumber(bytes);
            string        accountNumber = number.ToString();

            Assert.Equal(expectedNumber, accountNumber);
        }
        public void valid(string account)
        {
            var a = new AccountNumber(account);

            Assert.Equal(account, a.Value);
            Assert.Equal(account, a.ToString());
        }
Пример #7
0
        public void TestAccountNumberCreation()
        {
            var           expectedNumber = "123456789123456";
            var           bytes          = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6 };
            AccountNumber number         = new AccountNumber(bytes);
            string        accountNumber  = number.ToString();

            Assert.AreEqual(expectedNumber, accountNumber);
        }
Пример #8
0
        public string this[string columnName]
        {
            get
            {
                if (columnName == "AccountNumber" && !string.IsNullOrEmpty(AccountNumber))
                {
                    var accountNumberLength = AccountNumber.ToString().Length;
                    if (accountNumberLength > 10 || accountNumberLength < 5)
                    {
                        return("Account number length should be between 5 to 10. ");
                    }
                }
                else if (columnName == "AccountNumber1" && !string.IsNullOrEmpty(AccountNumber1))
                {
                    var accountNumberLength = AccountNumber1.ToString().Length;
                    if (AccountNumber1 != AccountNumber)
                    {
                        return("Account numbers do not match.");
                    }
                    else if (accountNumberLength > 10 || accountNumberLength < 5)
                    {
                        return("Account number length should be between 5 to 10. ");
                    }
                }
                else if (columnName == "Amount")
                {
                    if (Amount <= 0)
                    {
                        return("Amount should be more than zero.");
                    }
                }
                else if (columnName == "Email")
                {
                    if (string.IsNullOrEmpty(Email))
                    {
                        return(string.Empty);
                    }

                    return(!emailRegex.IsMatch(Email) ? "Email ID not in correct format." : null);
                }
                else if (columnName == "Password")
                {
                    if (string.IsNullOrEmpty(Password))
                    {
                        return(string.Empty);
                    }

                    if (Password != "password")
                    {
                        return("Password is incorrect");
                    }
                }

                return(string.Empty);
            }
        }
Пример #9
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'bankAccount.GetUID()'
        public string GetUID()
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'bankAccount.GetUID()'
        {
            if (AccountNumber != null)
            {
                return(AccountNumber.ToString(true, bankAccountNumberFormat.doubleSeparation));
            }
            else
            {
                return("");
            }
        }
Пример #10
0
 /// <param name="sender">sender account number</param>
 /// <param name="amount">amount to transfer</param>
 /// <param name="operationTitle">operation title</param>
 /// <param name="receiver">receiver  account number</param>
 public RestTransfer(AccountNumber sender, decimal amount,
                     string operationTitle, AccountNumber receiver)
     : base(receiver, new OperationRecord
 {
     Title  = operationTitle,
     Debet  = amount,
     Source = receiver.ToString()
 })
 {
     _restAdapter    = new RestAdapter(receiver, sender);
     _amount         = amount;
     _operationTitle = operationTitle;
 }
Пример #11
0
        private RestRequest CreateRequest(decimal amountToSend, string operationTitle)
        {
            var request = new RestRequest(Endpoint, Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(new RestTransferBody()
            {
                amount           = (int)amountToSend * 100,
                receiver_account = _receiver.ToString(),
                sender_account   = _sender.ToString(),
                title            = operationTitle
            });
            return(request);
        }
Пример #12
0
        protected override void Rollback()
        {
            if (!_operations[0].Executed)
            {
                return;
            }

            var rollback = new RollbackTransfer(_sender, _amount, _operationTitle, _receiverAccountNumber);

            _operations.Add(rollback);
            rollback.Execute();

            if (!_operations[1].Executed)
            {
                return;
            }

            var feeRollback = new RollbackTransferFee(_sender, TransferFeeValue, _receiverAccountNumber.ToString());

            _operations.Add(feeRollback);
            feeRollback.Execute();
        }
        public void Format_WillFormatAccountNumberInStandardPattern()
        {
            var accountNumber = new AccountNumber(0, 0, "0100");

            Assert.Equal(accountNumber.ToString("S", null), pattern.Format(accountNumber));
        }
        public void ShouldListNumberAsString()
        {
            var accountNumber = new AccountNumber("123456789");

            Assert.Equal("123456789", accountNumber.ToString());
        }
Пример #15
0
 /// <summary>
 /// Override default method ToString
 /// </summary>
 /// <returns>formatted string</returns>
 public override string ToString()
 {
     return(name + "," + AccountNumber.ToString() + "," + acctType.ToString() + "," + chargeAmt.ToString("c"));
 }
 public string ToDisplay()
 {
     return(AccountNumber.ToString() + "\t\t" + CustomerName + "\t" +
            "\t" + CustomerType.ToString() + "\t" + ChargeAmount.ToString());
 }
 public override string ToString()
 {
     return(CustomerName + "," + AccountNumber.ToString() + "," + CustomerType.ToString() + "," + ChargeAmount.ToString());
 }
Пример #18
0
        public IEnumerable GetErrors(string propertyName)
        {
            if (propertyName == null)
            {
                return(null);
            }

            List <string> errors = new List <string>();

            if (propertyName == "AccountNumber")
            {
                if (!string.IsNullOrEmpty(AccountNumber))
                {
                    propErrors.Remove("AccountNumber");
                    var accountNumberLength = AccountNumber.ToString().Length;
                    if (accountNumberLength > 10 || accountNumberLength < 5)
                    {
                        if (!propErrors.TryGetValue(propertyName, out errors))
                        {
                            errors = new List <string>();
                            errors.Add("Length should be between 5 and 10.");
                            propErrors.Add("AccountNumber", errors);
                        }
                    }
                    else if (propErrors.TryGetValue(propertyName, out errors))
                    {
                        errors.Clear();
                        propErrors.Remove(propertyName);
                    }
                }
                else if (propErrors.TryGetValue(propertyName, out errors))
                {
                    errors.Clear();
                    propErrors.Remove(propertyName);
                }
            }
            else if (propertyName == "AccountNumber1")
            {
                if (!string.IsNullOrEmpty(AccountNumber1))
                {
                    var accountNumberLength = AccountNumber1.ToString().Length;
                    var error = string.Empty;
                    if (AccountNumber1 != AccountNumber)
                    {
                        error = "Account numbers don't match.";
                    }
                    else if (accountNumberLength > 10 || accountNumberLength < 5)
                    {
                        error = "Length should be between 5 and 10.";
                    }
                    else if (propErrors.TryGetValue(propertyName, out errors))
                    {
                        errors.Clear();
                        propErrors.Remove(propertyName);
                    }
                    if (!propErrors.TryGetValue(propertyName, out errors) && !string.IsNullOrEmpty(error))
                    {
                        errors = new List <string>();
                        errors.Add(error);
                        propErrors.Add("AccountNumber1", errors);
                    }
                }
                else if (propErrors.TryGetValue(propertyName, out errors))
                {
                    errors.Clear();
                    propErrors.Remove(propertyName);
                }
            }
            else if (propertyName == "Amount")
            {
                if (Amount <= 0)
                {
                    if (!propErrors.TryGetValue(propertyName, out errors))
                    {
                        errors = new List <string>();
                        errors.Add("Amount should be greater than 0.");
                        propErrors.Add("Amount", errors);
                    }
                }
                else if (propErrors.TryGetValue(propertyName, out errors))
                {
                    errors.Clear();
                    propErrors.Remove(propertyName);
                }
            }
            else if (propertyName == "SWIFT")
            {
                if (string.IsNullOrEmpty(this.SWIFT))
                {
                    return(string.Empty);
                }
                if (!swiftRegex.IsMatch(this.SWIFT))
                {
                    if (!propErrors.TryGetValue(propertyName, out errors))
                    {
                        errors = new List <string>();
                        errors.Add("SWIFT code should be 8 or 11 upper case letters.");
                        propErrors.Add("SWIFT", errors);
                    }
                }
                else if (propErrors.TryGetValue(propertyName, out errors))
                {
                    errors.Clear();
                    propErrors.Remove(propertyName);
                }
            }
            else if (propertyName == "Password")
            {
                if (string.IsNullOrEmpty(this.Password))
                {
                    return(string.Empty);
                }

                var error = string.Empty;

                if (Password != "password")
                {
                    error = "Password is incorrect.";
                }

                if (!propErrors.TryGetValue(propertyName, out errors) && !string.IsNullOrEmpty(error))
                {
                    errors = new List <string>();
                    errors.Add(error);
                    propErrors.Add("Password", errors);
                }
                else if (propErrors.TryGetValue(propertyName, out errors))
                {
                    errors.Clear();
                    propErrors.Remove(propertyName);
                }
            }

            if (propErrors.TryGetValue(propertyName, out errors))
            {
                return(errors);
            }
            return(null);
        }
Пример #19
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 /// <returns>A string that represents the current object.</returns>
 public override string ToString()
 {
     return(AccountNumber.ToString() + " " + Firstname + " " + Lastname + " " + Balance.ToString() + " " + accountType.ToString() + " " + Bonus.ToString());
 }
Пример #20
0
        public void FullFormatWorksWithMaximumNumber()
        {
            var accountNumber = new AccountNumber(999999, 9999999999L, "0100");

            Assert.Equal("999999-9999999999/0100", accountNumber.ToString("F", null));
        }
Пример #21
0
 // display line in the text file
 public string ToFileLine()
 {
     return(CustomerType + "," + AccountNumber.ToString() + "," + CustName + "," + chargeAmount.ToString());
 }
Пример #22
0
 // overide ToString method to display string
 public override string ToString()
 {
     return(CustomerType + ", " + AccountNumber.ToString() + ", " + CustName + "--" + chargeAmount.ToString("c"));
 }
Пример #23
0
 public override string PrintAccount()
 {
     return(AccountNumber.ToString() + ": " + Balance + "  |Type: " + AccountType + " |Interest Rate: " + InterestRate + " |Status: " + Status.ToString());
 }
Пример #24
0
 public override string ToString()
 {
     return(AccountNumber.ToString());
 }
Пример #25
0
        public void FullFormatAlwaysHasFull6DigitsOfPrefix()
        {
            var accountNumber = new AccountNumber(0, 12, "0100");

            Assert.Equal("000000-0000000012/0100", accountNumber.ToString("F", null));
        }
Пример #26
0
 public override string ToString()
 {
     return("Account: " + AccountNumber.ToString() + "\r\nBalance: " + Balance.ToString());
 }
Пример #27
0
        public void FullFormatIsCaseInsensitive()
        {
            var accountNumber = new AccountNumber(0, 12, "0100");

            Assert.Equal(accountNumber.ToString("F", null), accountNumber.ToString("f", null));
        }
Пример #28
0
        public async void GetAccountInfomation()
        {
            await Execute(() =>
            {
                if (bAvailable)
                {
                    AccountBalance    = _apiClient.AccountBalance();
                    AccountEquity     = _apiClient.AccountEquity();
                    AccountFreeMargin = _apiClient.AccountFreeMargin();
                    AccountMargin     = _apiClient.AccountMargin();
                    AccountProfit     = _apiClient.AccountProfit();
                    AccountNumber     = _apiClient.AccountNumber();

                    string strAccountNumber, strFirst;
                    strAccountNumber = AccountNumber.ToString();
                    strFirst         = strAccountNumber.Substring(0, char.IsHighSurrogate(strAccountNumber[0]) ? 2 : 1);

                    if (strFirst == "2")
                    {
                        bIsWithSwap       = false;
                        dCommissionPerLot = 17;
                        bDemoAccount      = false;
                    }
                    else if (strFirst == "6")
                    {
                        bIsWithSwap       = true;
                        dCommissionPerLot = 17;
                        bDemoAccount      = false;
                    }
                    else if (strFirst == "7")
                    {
                        bIsWithSwap       = false;
                        dCommissionPerLot = 5;
                        bDemoAccount      = false;
                    }
                    else if (strFirst == "4")
                    {
                        bIsWithSwap       = true;
                        dCommissionPerLot = 17;
                        bDemoAccount      = true;
                    }
                    else
                    {
                        bIsWithSwap       = true;
                        dCommissionPerLot = 17;
                        bDemoAccount      = false;
                    }

                    // For test purpose only
                    if (strAccountNumber == "4009787")
                    {
                        bIsWithSwap = false;
                    }


                    string strSymbol = currentQuote.Instrument;
                    dSwapBuy         = GetSwapBuy(strSymbol);
                    dSwapSell        = GetSwapSell(strSymbol);
                    //if (dSwapBuy == 0 && dSwapSell == 0)
                    //    bIsWithSwap = false;
                    //else
                    //    bIsWithSwap = true;
                }
            });
        }
Пример #29
0
 public override string ToCSV()// for writing CSV file - no formatting
 {
     return(name + "," + AccountNumber.ToString() + "," + acctType.ToString() + "," + chargeAmt.ToString());
 }
Пример #30
0
        public void StandardFormatIsCaseInsensitive()
        {
            var accountNumber = new AccountNumber(0, 12, "0100");

            Assert.Equal(accountNumber.ToString("S", null), accountNumber.ToString("s", null));
        }