Esempio n. 1
0
        public void TestGetAccounts()
        {
            UnitTesting.SetupTesting();
            Customer c = new Customer("user", "pass");

            c.AddAccount(new CheckingAccount(1));
            c.AddAccount(new TermDeposit(2, 4000));
            c.AddAccount(new BusinessAccount(3));
            Assert.IsTrue(c.GetAccounts <IChecking>().Count == 2);
            UnitTesting.EndTest();
        }
        protected override void OnSetUp()
        {
            using (new TemporaryOffLog("NHibernate.SQL"))
                using (ISession s = OpenSession())
                    using (ITransaction tx = s.BeginTransaction())
                    {
                        //--------- Customer 1

                        Customer c = new Customer();
                        c.FirstName  = "Jose";
                        c.LastName   = "Flores";
                        c.CustomerId = "0001-1234";
                        c.City       = new City("Leandro N. Alem", "3315");
                        c.Born       = DateTime.Parse("12/12/1972");
                        c.AddAccount(new Account(1, MoneyType.Euro, true, DateTime.Parse("1/1/1981"), 1500d));
                        c.AddAccount(new Account(2, MoneyType.Dollar, true, DateTime.Today, 2000d));
                        s.Save(c);

                        //--------- Customer 2

                        Customer c2 = new Customer();
                        c2.FirstName  = "Jorge";
                        c2.LastName   = "Martinez";
                        c2.CustomerId = "0001-2343";
                        c2.City       = new City("Posadas", "3434");
                        c2.Born       = DateTime.Parse("1/1/1956");
                        c2.AddAccount(new Account(1, MoneyType.Euro, true, DateTime.Parse("1/1/1982"), 3500d));
                        c2.AddAccount(new Account(2, MoneyType.Dollar, false, DateTime.Today, 3000d));
                        c2.AddAccount(new Account(3, MoneyType.Dollar, true, DateTime.Today, 10000d));
                        s.Save(c2);


                        //--------- Customer 3

                        Customer c3 = new Customer();
                        c3.FirstName  = "Maria";
                        c3.LastName   = "Flores";
                        c3.CustomerId = "0001-3345";
                        c3.City       = new City("Posadas", "3434");
                        c3.Born       = DateTime.Parse("1/1/1960");
                        c3.AddAccount(new Account(1, MoneyType.Dollar, true, DateTime.Parse("1/1/1983"), 10000d));
                        s.Save(c3);

                        s.Flush();

                        tx.Commit();
                    }
        }
Esempio n. 3
0
        private void LoadSampleData()
        {
            Account acc1 = new Account(new List <Transaction> {
                new Transaction()
                {
                    ID = 1, Amount = -100, BalanceAccountNumber = 7654321, TransactionDate = DateTime.UtcNow
                }
            })
            {
                AccountNumber = 1234567
            };
            Account acc2 = new Account(new List <Transaction> {
                new Transaction()
                {
                    ID = 2, Amount = 100, BalanceAccountNumber = 1234567, TransactionDate = DateTime.UtcNow
                }
            })
            {
                AccountNumber = 7654321
            };
            Customer cust1 = new Customer()
            {
                Id = 1, Name = "M.I. Customer"
            };

            cust1.AddAccount(acc1);
        }
        public Customer CreateCustomer(string firstName, string lastName, string ssn)
        {
            var customer = new Customer(firstName, lastName, ssn);

            Random r             = new Random();
            var    accountNumber = (uint)r.Next(10000, 99999);

            var account = new Account(accountNumber, customer);

            customer.AddAccount(account);
            return(customer);
        }
        public Customer CreateCustomer(string firstName, string lastName, string socialSecurityNumber)
        {
            var customer = new Customer(firstName, lastName, socialSecurityNumber);

            var random = new Random();

            var accountNumbere = (uint)random.Next(10000, 99999);

            var account = new Account(accountNumbere, customer);

            customer.AddAccount(account);

            return(customer);
        }
Esempio n. 6
0
        public void AddAccountAddsAccount()
        {
            //Arrange
            Customer user = new Customer()
            {
                Id = 1, Name = "Test User"
            };
            int expectedResult = 1;

            //Act
            user.AddAccount(new Account());
            int actualResult = user.GetAccounts().Count();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Esempio n. 7
0
        public void RemoveAccountRemovesAccount()
        {
            //Arrange
            Account  acc  = new Account();
            Customer user = new Customer()
            {
                Id = 1, Name = "Test User"
            };

            user.AddAccount(acc);
            int expectedResult = 0;

            //Act
            user.RemoveAccount(acc);
            int actualResult = user.GetAccounts().Count();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }