Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IAccountService    service = resolver.Get <IAccountService>();
            IAccountGenerateID creator = resolver.Get <IAccountGenerateID>();

            service.OpenNewAccount(creator.GenerateID(), AccountType.Base, "Alexey", "Sidorov", 0, 0);
            service.OpenNewAccount(creator.GenerateID(), AccountType.Base, "John", "Newman", 1000, 10);
            service.OpenNewAccount(creator.GenerateID(), AccountType.Gold, "Keron", "Walsen", 250, 0);
            service.OpenNewAccount(creator.GenerateID(), AccountType.Base, "Alisa", "Dvachevskaya", 330, 50);

            var accounts = service.GetAllAccounts();

            foreach (var acc in accounts)
            {
                service.AccountReplenishment(acc, 100);
            }

            foreach (var acc in accounts)
            {
                Console.WriteLine(acc);
            }

            foreach (var acc in accounts)
            {
                service.AccountWriteOff(acc, 10);
            }

            foreach (var acc in accounts)
            {
                Console.WriteLine(acc);
            }

            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void BankSystemTest2()
        {
            resolver = new StandardKernel();
            resolver.ConfigurateResolver();
            IAccountGenerateID service = resolver.Get <IAccountGenerateID>();

            var anObject = service.GenerateID();

            Assert.IsNotNull(anObject);
            Assert.IsNotEmpty(anObject);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds new account to the list
        /// </summary>
        public void OpenNewAccount(IAccountGenerateID generator, AccountType type, string name, string surname, int cash, int bonus)
        {
            if (generator == null)
            {
                throw new ArgumentNullException();
            }

            string id = generator.GenerateID();

            AccountValidation.CheckInput(id, type, name, surname, cash, bonus);

            Account account = new Account(id, type, name, surname, cash, bonus);

            _allAccounts.Add(account);
            _accountRepository.AddAccount(account.ConvertToDalAccount());
        }