Exemple #1
0
        public virtual void ObjectsAreReused()
        {
            Helper1 helper1 = new Helper1();
            Helper2 helper2 = new Helper2()
            {
                Helper = helper1
            };

            List <Helper2> source = new List <Helper2>()
            {
                helper2,
                helper2,
            };

            var target = GetClone(source, 3);

            Assert.NotNull(target);
            Assert.Equal(target.Count, source.Count);

            Assert.NotSame(target, source);

            Assert.NotSame(target[0], source[0]);
            Assert.NotSame(target[0], helper1);
            Assert.NotSame(target[0].Helper, source[0].Helper);
            Assert.NotSame(target[0].Helper, helper2);

            Assert.NotSame(target[1], source[1]);
            Assert.NotSame(target[1], helper1);
            Assert.NotSame(target[1].Helper, source[1].Helper);
            Assert.NotSame(target[1].Helper, helper2);

            Assert.Same(target[0], target[1]);
            Assert.Same(target[0].Helper, target[1].Helper);
        }
Exemple #2
0
        public void ListOfClasses_DuplicateReuse()
        {
            Helper1 tmp = new Helper1();

            IReadOnlyList <Helper1> source = new List <Helper1>()
            {
                tmp,
                tmp,
                tmp
            };

            var dest = GetClone(source, 2);

            Assert.NotNull(dest);
            Assert.NotEqual(dest, source);
            Assert.NotSame(dest, source);
            Assert.Equal(dest.Count, source.Count);

            var firstItem = dest[0];

            for (int i = 0; i < dest.Count; i++)
            {
                Assert.NotSame(source[i], dest[i]);
                Assert.Same(firstItem, dest[i]);
            }
        }
Exemple #3
0
        public virtual void Null()
        {
            Helper1 source = null;
            var     dest   = GetClone(source, 0);

            Assert.Null(dest);
        }
        public static void RegisterCustomer()
        {
            var _customerInstance = ClassNewers.CustomerCreator();

            bool active = false;

            while (!active)
            {
                Helper1.Logger("Enter your email Address");
                _customerInstance.EmailAddress = Validate.ValidateMail();

                Helper1.Logger("Enter your FirstName");
                _customerInstance.FirstName = Validate.ValidateName();

                Helper1.Logger("Enter your LastName");
                _customerInstance.LastName = Helper1.Reader();

                Helper1.Logger("Enter your Password");;
                _customerInstance.Password = Validate.ValidatePassword();

                CustomerDataStore.SaveCustomer(_customerInstance);
                RegisterAccountInitial(_customerInstance);
                active = true;

                Console.Clear();
            }
        }
        public static void InitialDeposit(CustomerDetails customer, decimal defaultValue, IAccounts account)
        {
            try
            {
                var _AccountNumber = account.AccountNumber;

                Helper1.Logger("Enter amount to deposit");
                var _amountToDeposit = Console.ReadLine();

                var value = Convert.ToDecimal(_amountToDeposit);

                if (value > defaultValue)
                {
                    if (account.AccountOwner == customer)
                    {
                        Helper1.Logger("Enter transaction description");
                        account.Note = Helper1.Reader();

                        account.AccountBalance += value;


                        var transactDetails = ClassNewers.TransactionDetailsCreator(account);
                        transactDetails.TransactionAmount = value;
                        transactDetails.AccountBalance    = account.AccountBalance;
                        transactDetails.Note = account.Note;

                        AccountsDataStore.SaveTransactionDetails(transactDetails);

                        Helper1.Logger("Transaction Successful");
                        Helper1.Logger($"Your new account balance is #{account.AccountBalance}");
                    }
                    else
                    {
                        Helper1.Logger("The details you entered were incorrect, make sure the account number you eneterd is yours");
                        InitialDeposit(customer, defaultValue, account);
                    }
                }
                else
                {
                    Helper1.Logger($"The amount must be at least eqaul to {defaultValue}");
                    InitialDeposit(customer, defaultValue, account);
                }
            }
            catch (FormatException)
            {
                Helper1.Logger("Account Number Must be a number");
                InitialDeposit(customer, defaultValue, account);
            }
            catch (Exception)
            {
                Helper1.Logger("No such account exists in our Database");
                InitialDeposit(customer, defaultValue, account);
            }
        }
Exemple #6
0
        public void RegisterType_CallContainerRegisterMethodLifeCycleSingleton_TypeRegisteredSucessful()
        {
            //Arrange
            IContainer container = new Container();
            Helper1    help1     = new Helper1();

            //Act
            container.Register <IHelper1, Helper1>(LifeCycle.Singleton);
            var actualType1 = container.Resolve <IHelper1>();

            //Assert
            Assert.IsType(help1.GetType(), actualType1);
        }
Exemple #7
0
        public void RegisterCompositeType_CallContainerResolveMethod_ShouldThrowTypeNotRegisteredException()
        {
            //Arrange
            IContainer container = new Container();
            IHelper1   help1     = new Helper1();

            //Act
            Exception ex = Assert.Throws <TypeNotRegisteredException>(() => container.Resolve <IHelper1>());


            //Assert
            Assert.Equal("The type IHelper1 has not been registered", ex.Message);
        }
Exemple #8
0
        public void RegisterType_CallContainer_TypesAreRegisteredAndResolvedBytype()
        {
            //Arrange
            IContainer container = new Container();
            IHelper1   help1     = new Helper1();

            //Act
            container.Register <IHelper1, Helper1>();
            var actualType1 = container.Resolve(typeof(IHelper1));

            //Assert
            Assert.IsType(help1.GetType(), actualType1);
        }
Exemple #9
0
        public void CompositeClassNoDependenciesRegistered_CallContainerResolveMethod_ShouldThrowFailedToCreateInstanceException()
        {
            //Arrange
            IContainer          container     = new Container();
            Helper1             help1         = new Helper1();
            Helper2             help2         = new Helper2();
            ICompositeItemWrong compositeItem = new CompositeItemWrong(help1, help2);

            container.Register <ICompositeItemWrong, CompositeItemWrong>();

            //Act
            Exception ex = Assert.Throws <FailedToCreateInstanceException>(() => container.Resolve <ICompositeItemWrong>());

            //Assert
            Assert.Equal("Can't create instance of type CompositeItemWrong", ex.Message);
        }
Exemple #10
0
        public static void CustomerLogger()
        {
            Console.Clear();
            bool active = false;

            while (!active)
            {
                //Checks that the Databse is not empty before allowing any user access to log-in.
                if (CustomerDataStore.DataStoreCount())
                {
                    CustomerDetails foundUser = null;
                    Helper1.Logger("Please enter your log-in details");

                    Helper1.Logger("Please enter your registered email Address");
                    var Login_mail = Helper1.Reader();

                    Helper1.Logger("Please enter your password");
                    var Login_password = Helper1.Reader();

                    //Checks to see that the user attempting to log-in actually exists in the Database
                    var user1 = CustomerDataStore.FindCustomerByMail(Login_mail);
                    var user2 = CustomerDataStore.FindCustomerByPassword(Login_password);
                    if (user1 != null && user2 != null && user1 == user2)
                    {
                        Helper1.Logger("Welcome you are logged in");
                        Helper1.Reader();
                        foundUser = user1;

                        MainUserInterface.ActivityPage(foundUser);
                        active = true;
                    }
                    else
                    {
                        Console.WriteLine("Sorry, this user does not exist in our database");
                        Console.ReadKey();
                        active = true;
                    }
                }
                else
                {
                    Console.WriteLine("There are currently no users in the database. Rgister first");
                    Console.ReadKey();
                    active = true;
                }
                break;
            }
        }
Exemple #11
0
        public void RegisterType_TwoDifferentImplementationsTwoDifferentInterfaces_TypesAreRegisteredAndResolved()
        {
            //Arrange
            IContainer container = new Container();
            Helper1    help1     = new Helper1();
            Helper2    help2     = new Helper2();

            //Act
            container.Register <IHelper1, Helper1>();
            container.Register <IHelper2, Helper2>();
            var actualType1 = container.Resolve <IHelper1>();
            var actualType2 = container.Resolve <IHelper2>();

            //Assert
            Assert.IsType(help1.GetType(), actualType1);
            Assert.IsType(help2.GetType(), actualType2);
        }
Exemple #12
0
        public void RegisterType_OneInterfaceTwoDifferentImplementations_TypesAreRegisteredAndResolvedByType()
        {
            //Arrange
            Container container = new Container();
            IHelper1  help1     = new Helper1();
            IHelper1  help2     = new Helper2();

            //Act
            container.Register <IHelper1, Helper1>();
            container.Register <IHelper1, Helper2>();
            List <object> actualTypes = container.ResolveAll(typeof(IHelper1)).ToList();

            //Assert
            Assert.NotNull(actualTypes);
            Assert.Equal(help1.GetType().FullName, actualTypes[0].GetType().FullName);
            Assert.Equal(help2.GetType().FullName, actualTypes[1].GetType().FullName);
        }
        public static void RegisterAccountInitial(CustomerDetails customer)
        {
            bool active = false;

            while (!active)
            {
                Console.Clear();
                Helper1.Logger("Please follow the prompt to create a bank account and complete your registeration process");
                Helper1.Logger(@"Enter:
                    '1' to create a savings account
                    '2' to create a current account
                               ");
                var value = Helper1.Reader();

                switch (value)
                {
                case "1":
                    var _savingsAccountInstance = ClassNewers.SavingsAccountCreator(customer);
                    AccountsDataStore.SaveAccount(_savingsAccountInstance);
                    Helper1.Logger($"Welcome you have successfully registerd a savings account.\n" +
                                   $" Your Account number is {_savingsAccountInstance.AccountNumber}");
                    var _accountnumber = _savingsAccountInstance.AccountNumber;
                    var account        = AccountsDataStore.ExistChecker(_accountnumber);
                    account.MakeInitialDeposit(customer, account);
                    Console.ReadKey();
                    active = true;
                    break;

                case "2":
                    var _currentAccountInstance = ClassNewers.CurrentAccountCreator(customer);
                    AccountsDataStore.SaveAccount(_currentAccountInstance);
                    Helper1.Logger($"Welcome you have successfully registerd a current account.\n" +
                                   $"Your Account number is {_currentAccountInstance.AccountNumber}");
                    var _accountnumber1 = _currentAccountInstance.AccountNumber;
                    var account1        = AccountsDataStore.ExistChecker(_accountnumber1);
                    account1.MakeInitialDeposit(customer, account1);
                    Console.ReadKey();
                    active = true;
                    break;

                default:
                    break;
                }
            }
        }
Exemple #14
0
        public void RegisterCompositeType_CallContainer_TypesAreRegisteredAndResolvedbyType()
        {
            //Arrange
            IContainer     container     = new Container();
            Helper1        help1         = new Helper1();
            Helper2        help2         = new Helper2();
            ICompositeItem compositeItem = new CompositeItem(help1, help2);


            //Act
            container.Register <IHelper1, Helper1>();
            container.Register <IHelper2, Helper2>();
            container.Register <ICompositeItem, CompositeItem>();
            var actualType = container.Resolve(typeof(ICompositeItem));

            //Assert
            Assert.IsType(compositeItem.GetType(), actualType);
        }
Exemple #15
0
        public static void Mainmenu()
        {
            var exit = false;

            while (!exit)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.DarkCyan;

                Console.WriteLine("Hello");
                Console.WriteLine("Welcome to the Kingdom Mobile Bank App");
                Console.WriteLine("Designed by AKPAKA CHIBUIKEM ROWLAND");
                Console.WriteLine(@"Please Enter:
                        'L' to log-in 
                        'R' to register
                        'E' to exit the app");

                var UserChoice = Helper1.Reader();
                if (UserChoice.ToUpper() == "L")
                {
                    //Redirects to Log-in User Interface
                    Console.Clear();
                    Log_inUserInterface.CustomerLogger();
                }

                else if (UserChoice.ToUpper() == "R")
                {
                    //Redirects to registeration User Interface
                    RegisterationUserInterface.RegisterCustomer();
                }
                else if (UserChoice.ToUpper() == "E")
                {
                    //Exits Application
                    Console.WriteLine("bye");
                    exit = true;
                }
            }
        }
Exemple #16
0
        public void ArrayOfClasses()
        {
            Helper1[] source = new Helper1[1000];

            for (int i = 0; i < source.Length; i++)
            {
                source[i] = new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                };
            }

            var dest = GetClone(source, 1001);

            Assert.NotNull(dest);
            Assert.Equal(dest.Length, source.Length);

            for (int i = 0; i < dest.Length; i++)
            {
                Assert.NotSame(dest[i], source[i]);
                Assert.Equal(dest[i].PropOne, source[i].PropOne);
            }
        }
        public static void Deposit(CustomerDetails customer, IAccounts account)
        {
            bool active = false;

            while (!active)
            {
                Helper1.Logger("Enter Account Number to Deposit funds to");
                try
                {
                    var _AccountNumber = account.AccountNumber;

                    Helper1.Logger("Enter amount to deposit");
                    var _amountToDeposit = Console.ReadLine();

                    var value = Convert.ToDecimal(_amountToDeposit);

                    if (value > 0)
                    {
                        if (account.AccountOwner == customer)
                        {
                            Helper1.Logger("Enter transaction description");
                            account.Note = Helper1.Reader();

                            account.AccountBalance += value;


                            var transactDetails = ClassNewers.TransactionDetailsCreator(account);
                            transactDetails.TransactionAmount = value;
                            transactDetails.AccountBalance    = account.AccountBalance;
                            transactDetails.Note = account.Note;

                            AccountsDataStore.SaveTransactionDetails(transactDetails);

                            Helper1.Logger("Transaction Successful");
                            Helper1.Logger($"Your new account balance is #{account.AccountBalance}");

                            active = true;
                        }
                        else
                        {
                            Helper1.Logger("The details you entered were incorrect, make sure the account number you eneterd is yours");
                            Thread.Sleep(1500);
                            active = true;
                        }
                    }
                    else
                    {
                        Helper1.Logger("The amount must be a greater than zer0");
                        Thread.Sleep(1500);
                    }
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account Number Must be a number");
                    Thread.Sleep(1500);
                    active = true;
                }
                catch (Exception)
                {
                    Helper1.Logger("No such account exists in our Database");
                    Thread.Sleep(1500);
                    active = true;
                }
            }
        }
        public static void Transfer(CustomerDetails customer, int defaultAmount, IAccounts accounts)
        {
            bool active = false;

            while (!active)
            {
                Helper1.Logger("Enter Account Number to transfer funds to");
                var _accountToTransferTo = Helper1.Reader();


                try
                {
                    var beneficiary = Convert.ToInt32(_accountToTransferTo);
                    var useraccount = accounts.AccountNumber;

                    var checker1 = AccountsDataStore.FindAccount(beneficiary);

                    if (accounts.AccountOwner == customer)
                    {
                        Helper1.Logger("Enter amount to transfer");
                        var _amountToTransfer = Helper1.Reader();

                        var value = Convert.ToDecimal(_amountToTransfer);
                        if (value >= 0)
                        {
                            if (value < accounts.AccountBalance && accounts.AccountBalance > defaultAmount)
                            {
                                Helper1.Logger("Please enter your password for additional security");
                                var authpassword = Helper1.Reader();

                                if (authpassword == customer.Password)
                                {
                                    Helper1.Logger("Enter transaction description");
                                    accounts.Note = Helper1.Reader();

                                    accounts.AccountBalance -= value;
                                    checker1.AccountBalance += value;

                                    var transactDetails = ClassNewers.TransactionDetailsCreator(accounts);
                                    transactDetails.TransactionAmount = value;
                                    transactDetails.AccountBalance    = checker1.AccountBalance;
                                    transactDetails.Note = checker1.Note;
                                    AccountsDataStore.SaveTransactionDetails(transactDetails);

                                    var transactDetails1 = ClassNewers.TransactionDetailsCreator(checker1);
                                    transactDetails.TransactionAmount = value;
                                    transactDetails.AccountBalance    = checker1.AccountBalance;
                                    transactDetails.Note = checker1.Note;
                                    AccountsDataStore.SaveTransactionDetails(transactDetails);


                                    Helper1.Logger("Transaction Successful");
                                    Helper1.Logger($"Your new account balance is #{accounts.AccountBalance}");

                                    active = true;
                                }
                                else
                                {
                                    Helper1.Logger("Password is incorrect");
                                    Thread.Sleep(2000);
                                    active = true;
                                }
                            }
                            else
                            {
                                Helper1.Logger("Your account balance is insufficient");
                                Thread.Sleep(1500);
                                active = true;
                            }
                        }
                        else
                        {
                            Helper1.Logger("Amount must be a positive number");
                        }
                    }
                    else
                    {
                        Helper1.Logger("The details you entered were incorrect, ensure the account number you eneterd is yours");
                        Thread.Sleep(1500);
                        active = true;
                    }
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account number must be a number");
                    Thread.Sleep(1500);
                    active = true;
                }
                catch (Exception)
                {
                    Helper1.Logger("No such account exists in our Database");
                    Thread.Sleep(1500);
                    active = true;
                }
            }
        }
        public static void Withdraw(CustomerDetails customer, int defaultAmount, IAccounts account)
        {
            bool active = false;

            while (!active)
            {
                try
                {
                    var _AccountNumber = account.AccountNumber;

                    if (account.AccountOwner == customer)
                    {
                        Helper1.Logger("Enter amount to withdraw");
                        var _amountToTransfer = Helper1.Reader();


                        var value = Convert.ToDecimal(_amountToTransfer);
                        if (value > 0)
                        {
                            if (value < account.AccountBalance && account.AccountBalance > defaultAmount)
                            {
                                Helper1.Logger("Please enter your password for additional security");
                                var authpassword = Console.ReadLine();


                                if (authpassword == customer.Password)
                                {
                                    Helper1.Logger("Enter transaction description");
                                    account.Note = Helper1.Reader();

                                    account.AccountBalance -= value;


                                    var transactDetails = ClassNewers.TransactionDetailsCreator(account);
                                    transactDetails.TransactionAmount = value;
                                    transactDetails.AccountBalance    = account.AccountBalance;
                                    transactDetails.Note = account.Note;

                                    AccountsDataStore.SaveTransactionDetails(transactDetails);

                                    Helper1.Logger("Transaction Successful");
                                    Helper1.Logger($"Your new account balance is #{account.AccountBalance}");

                                    active = true;
                                }
                                else
                                {
                                    Helper1.Logger("Passowrd is Incorrect");
                                    Thread.Sleep(1500);
                                    active = true;
                                }
                            }
                            else
                            {
                                Helper1.Logger("Your account balance is insufficient");
                                Thread.Sleep(1500);
                                active = true;
                            }
                        }
                        else
                        {
                            Helper1.Logger("Amount must be a positive Integer");
                            Thread.Sleep(1500);
                        }
                    }
                    else
                    {
                        Helper1.Logger("The details you entered were incorrect, make sure the account number you eneterd is yours");
                        Thread.Sleep(1500);
                        active = true;
                    }

                    ;
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account Number must be a number");
                    Thread.Sleep(1500);
                    active = true;
                }
                catch (Exception)
                {
                    Helper1.Logger("No such account exists in our Database");
                    Thread.Sleep(1500);
                    active = true;
                }
            }
        }
        public static void GetBalance(CustomerDetails customer, IAccounts account)
        {
            bool active = false;

            while (!active)
            {
                Helper1.Logger("Enter Account Number to get balance from");

                try
                {
                    var _AccountNumber = account.AccountNumber;;

                    if (account.AccountOwner == customer)
                    {
                        Helper1.Logger("Please Enter your passord for additional security");
                        var authpassword = Console.ReadLine();

                        if (authpassword == customer.Password)
                        {
                            if (account.AccountBalance >= 1010.23m)
                            {
                                var value = 10.23m;

                                account.Note = "Get Balance";

                                account.AccountBalance -= value;

                                var transactDetails = ClassNewers.TransactionDetailsCreator(account);
                                transactDetails.TransactionAmount = value;
                                transactDetails.AccountBalance    = account.AccountBalance;
                                transactDetails.Note = account.Note;

                                AccountsDataStore.SaveTransactionDetails(transactDetails);

                                Helper1.Logger("Transaction Successful");
                                Helper1.Logger($" Your Account Balance for {account.AccountNumber} is {account.AccountBalance} as at {DateTime.Now}");

                                active = true;
                            }
                            else
                            {
                                Helper1.Logger("Your Account is insufficient please make a deposit and try again. Thank you");
                                Thread.Sleep(1500);
                                active = true;
                            }
                        }
                        else
                        {
                            Helper1.Logger("Your password is incorrect");
                            Thread.Sleep(1500);
                            active = true;
                        }
                    }
                    else
                    {
                        Helper1.Logger("The details you entered were incorrect, ensure the account number you eneterd is yours");
                        Thread.Sleep(1500);
                        active = true;
                    }
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account number must be a number");
                    Thread.Sleep(1500);
                    active = true;
                }
                catch (Exception)
                {
                    Helper1.Logger("No such account exists in our Database");
                    Thread.Sleep(1500);
                    active = true;
                }
            }
        }
Exemple #21
0
        public static void ActivityPage(CustomerDetails customer)
        {
            Console.Clear();
            bool active = false;

            while (!active)
            {
                try
                {
                    Console.Clear();

                    Console.WriteLine("->> Welcome to the Kingdom School Admin Home page; we hope you have a wonderful experience");

                    Console.WriteLine("Please follow the prompt to update your details");
                    Console.WriteLine(@"Enter:
                    '1' to Deopsit funds
                    '2' to Withdraw funds
                    '3' to transfer funds
                    '4' to Get your account balance
                    '5' to get your statement of account
                    '6' to create a new savings account
                    '7' to create a new current account
                    '0' to Log out");
                    var value = Console.ReadLine();
                    switch (value)
                    {
                    case "1":
                        Helper1.Logger("Enter The account number to deposiit funds into");
                        var value1          = Convert.ToInt32(Helper1.Reader());
                        var _accountnumber1 = value1;
                        var account1        = AccountsDataStore.ExistChecker(_accountnumber1);
                        account1.DepositFunds(customer, account1);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "2":
                        Helper1.Logger("Enter your account number");
                        var value2          = Convert.ToInt32(Helper1.Reader());
                        var _accountnumber2 = value2;
                        var account2        = AccountsDataStore.ExistChecker(_accountnumber2);
                        account2.WithdrawFunds(customer, account2);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "3":
                        Helper1.Logger("Enter your account number");
                        var value3          = Convert.ToInt32(Helper1.Reader());
                        var _accountnumber3 = value3;
                        var account3        = AccountsDataStore.ExistChecker(_accountnumber3);
                        account3.TransferFunds(customer, account3);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "4":
                        Helper1.Logger("Enter The account number to get balance from");
                        var value4          = Convert.ToInt32(Helper1.Reader());
                        var _accountnumber4 = value4;
                        var account4        = AccountsDataStore.ExistChecker(_accountnumber4);
                        account4.GetBalance(customer, account4);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "5":
                        Helper1.Logger("Enter The account number to get statemnt from");
                        var value5          = Convert.ToInt32(Helper1.Reader());
                        var _accountnumber5 = value5;
                        var account5        = AccountsDataStore.ExistChecker(_accountnumber5);
                        account5.GetStatement(customer, account5);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "6":
                        var _savingsAccountInstance = ClassNewers.SavingsAccountCreator(customer);
                        AccountsDataStore.SaveAccount(_savingsAccountInstance);
                        Helper1.Logger($"Welcome you have successfully registerd your Account number is {_savingsAccountInstance.AccountNumber}");
                        var _accountnumber = _savingsAccountInstance.AccountNumber;
                        var account        = AccountsDataStore.ExistChecker(_accountnumber);
                        account.MakeInitialDeposit(customer, account);
                        Console.ReadKey();
                        Console.ReadLine();
                        break;

                    case "7":
                        var _currentAccountInstance = ClassNewers.CurrentAccountCreator(customer);
                        AccountsDataStore.SaveAccount(_currentAccountInstance);
                        Helper1.Logger($"Welcome you have successfully registerd your Account number is {_currentAccountInstance.AccountNumber}");
                        var _accountnumber7 = _currentAccountInstance.AccountNumber;
                        var account7        = AccountsDataStore.ExistChecker(_accountnumber7);
                        account7.MakeInitialDeposit(customer, account7);
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    case "0":
                        active = true;
                        Console.WriteLine("Thank YOU FOR VISITING");
                        Console.ReadKey();
                        Console.Clear();
                        break;

                    default:
                        break;
                    }
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account must be a number");
                    Thread.Sleep(1500);
                }
                catch (Exception)
                {
                    Helper1.Logger("There was an Error in your input please try again");
                    Thread.Sleep(1500);
                }
            }
        }
Exemple #22
0
 /// <summary>
 ///     Шифрует строку с помощью пароля и некоторых алгоритмов шифрования. Возвращает строку в кодировке Base64
 /// </summary>
 /// <param name="Text">Входной текст</param>
 /// <param name="Pass">Пароль для шифровки</param>
 /// <returns></returns>
 public string Encode(string Text, string Pass)
 {
     return(Helper2.Encrypt(Helper1.Encrypt(Text), Pass));
 }
Exemple #23
0
 /// <summary>
 ///     Расшифровывает строку в кодировке Base64, возвращает string
 /// </summary>
 /// <param name="EncodedText">Зашифрованный текст в формате Base64</param>
 /// <param name="Pass">Пароль для дешифровки</param>
 /// <returns></returns>
 public string Decode(string EncodedText, string Pass)
 {
     return(Helper2.Decrypt(Helper1.Decrypt(EncodedText), Pass));
 }
Exemple #24
0
        public void Setup()
        {
            _null = null;

            _simpleClass = new Helper1()
            {
                PropOne   = RandGen.GenerateInt(),
                PropTwo   = RandGen.GenerateInt(),
                PropThree = RandGen.GenerateInt(),
            };

            _complexClass = new Helper2()
            {
                Helper = new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                    PropFour  = RandGen.GenerateInt(),
                    PropFive  = RandGen.GenerateInt(),
                    PropSix   = RandGen.GenerateInt(),
                    PropSeven = RandGen.GenerateInt(),
                    PropEight = RandGen.GenerateInt(),
                    PropNine  = RandGen.GenerateInt(),
                    PropTen   = RandGen.GenerateInt()
                }
            };

            _inheritListClass = new Helper3 <Helper1>()
            {
                PropOne = RandGen.GenerateInt()
            };

            for (int i = 0; i < 10000; i++)
            {
                _inheritListClass.Add(new Helper1()
                {
                    PropOne = RandGen.GenerateInt()
                });
            }
            ;

            _inheritListInt = new Helper3 <int>();

            for (int i = 0; i < 10000; i++)
            {
                _inheritListInt.Add(RandGen.GenerateInt());
            }
            ;

            _grandChildClass = GrandChildClassHelper.Generate();

            _listSimpleClasses = new List <Helper1>();

            for (int i = 0; i < 10000; i++)
            {
                _listSimpleClasses.Add(new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                });
            }

            _listComplexClasses = new List <Helper2>();

            for (int i = 0; i < 10000; i++)
            {
                _listComplexClasses.Add(new Helper2()
                {
                    Helper = new Helper1()
                    {
                        PropOne   = RandGen.GenerateInt(),
                        PropTwo   = RandGen.GenerateInt(),
                        PropThree = RandGen.GenerateInt(),
                    }
                });
            }

            _listInterfaces = new List <MyTmpInterface>();

            for (int i = 0; i < 10000; i++)
            {
                _listInterfaces.Add(new Helper1());
                _listInterfaces.Add(new Helper1_1());
            }

            _listSimpleStructs = new List <HelperStruct1>();

            for (int i = 0; i < 10000; i++)
            {
                _listSimpleStructs.Add(new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt(),
                });
            }

            _listComplexStructs = new List <HelperStruct2>();

            for (int i = 0; i < 10000; i++)
            {
                _listComplexStructs.Add(new HelperStruct2()
                {
                    Helper = new HelperStruct1()
                    {
                        PropOne   = RandGen.GenerateInt(),
                        PropTwo   = RandGen.GenerateInt(),
                        PropThree = RandGen.GenerateInt(),
                    }
                });
            }

            _dictOfStructs = new Dictionary <HelperStruct1, HelperStruct1>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfStructs.Add(
                    new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                },
                    new HelperStruct1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                });
            }

            _dictOfClasses = new Dictionary <Helper1, Helper1>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfClasses.Add(
                    new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                },
                    new Helper1()
                {
                    PropOne   = RandGen.GenerateInt(),
                    PropTwo   = RandGen.GenerateInt(),
                    PropThree = RandGen.GenerateInt()
                });
            }

            _dictOfInt = new Dictionary <int, int>();

            for (int i = 0; i < 10000; i++)
            {
                _dictOfInt.Add(i, RandGen.GenerateInt());
            }

            _listSimpleClassesAsInterfaces = _listSimpleClasses
                                             .OfType <MyTmpInterface>()
                                             .ToList();

            _listSimpleClassesAsObjects = _listSimpleClasses
                                          .Cast <object>()
                                          .ToList();
        }
        public static void GetStatement(CustomerDetails customer, IAccounts account)
        {
            bool active = false;

            while (!active)
            {
                try
                {
                    var _AccountNumber = account.AccountNumber;

                    if (account.AccountOwner == customer)
                    {
                        Helper1.Logger("Please Enter your passord for additional security");
                        var authpassword = Console.ReadLine();

                        if (authpassword == customer.Password)
                        {
                            if (account.AccountBalance >= 1019.4m)
                            {
                                var value = 19.14m;
                                account.AccountBalance -= value;

                                account.Note = "Get statement of Account";


                                var transactDetails = ClassNewers.TransactionDetailsCreator(account);

                                transactDetails.TransactionAmount = value;
                                transactDetails.AccountBalance    = account.AccountBalance;
                                transactDetails.Note = account.Note;

                                AccountsDataStore.SaveTransactionDetails(transactDetails);

                                var _statement = AccountsDataStore.FindTransactions(_AccountNumber);
                                foreach (var transaction in _statement)
                                {
                                    Console.WriteLine("{0}  ||   {1}  ||  {2}  ||   {3}  ||  {4}  ||  {5}  ||   {6}",
                                                      transaction.AccountOwnerName, transaction.AccountNumber,
                                                      transaction.AccountType,
                                                      transaction.TransactionAmount, transaction.AccountBalance,
                                                      transaction.Note, transaction.TransactionTime);
                                }

                                Helper1.Logger("Transaction Successful");

                                active = true;
                            }
                            else
                            {
                                Helper1.Logger("Your account balance is insufficient, please credit your account and try again. Thank you.");
                                Thread.Sleep(1500);
                                active = true;
                            }
                        }
                        else
                        {
                            Helper1.Logger("Your password is incorrect");
                            Thread.Sleep(1500);
                            active = true;
                        }
                    }
                    else
                    {
                        Helper1.Logger("The details you entered were incorrect, ensure the account number you eneterd is yours");
                        Thread.Sleep(1500);
                        active = true;
                    }
                }
                catch (FormatException)
                {
                    Helper1.Logger("Account number must be a number");
                    Thread.Sleep(1500);
                    active = true;
                }
                catch (Exception)
                {
                    Helper1.Logger("No such account exists in our Database");
                    Thread.Sleep(1500);
                    active = true;
                }
            }
        }