public void TransactionRollbackTest()
        {
            PeopleRepository peopleRepository = new PeopleRepository();
            AccountsRepository accountsRepository = new AccountsRepository();
            BankDataContextFactory contextFactory = new BankDataContextFactory();

            Person createdPerson = new Person();
            createdPerson.Name = "transaction test";
            createdPerson.Document = "ZGMFX20A";
            createdPerson.Email = "*****@*****.**";

            Account createdAccount = new Account();
            createdAccount.Number = 2354235;
            createdAccount.Agency = 34;

            UnitOfWork unitOfWork = contextFactory.CreateUnitOfWork();

            peopleRepository.Save(createdPerson, unitOfWork);

            createdAccount.OwnerId = createdPerson.Id;

            accountsRepository.Save(createdAccount, unitOfWork);

            unitOfWork.Rollback();

            Assert.IsNull(peopleRepository.FindSingle(p => p.Name == createdPerson.Name));
            Assert.IsNull(accountsRepository.FindSingle(a => a.Number == createdAccount.Number));
        }
        public void CreateFindUpdateTest()
        {
            Person createdPerson = new Person();
            createdPerson.Name = "gandamu strike freedom";
            createdPerson.Document = "ZGMFX20A";
            createdPerson.Email = "*****@*****.**";

            PeopleRepository peopleRepository = new PeopleRepository();

            peopleRepository.Save(createdPerson);

            Account createdAccount = new Account();
            createdAccount.Agency = 435;
            createdAccount.Number = 123123123;
            createdAccount.OwnerId = createdPerson.Id;

            AccountsRepository repository = new AccountsRepository();

            repository.Save(createdAccount);

            Assert.AreNotEqual(0, createdAccount.Id);

            Account retrievedAccount = repository.FindSingle(a => a.Id == createdAccount.Id);

            Assert.AreEqual(createdAccount, retrievedAccount);

            retrievedAccount.Agency = 666;

            repository.Save(retrievedAccount);

            retrievedAccount = repository.FindSingle(a => a.Id == createdAccount.Id);

            Assert.AreEqual(666, retrievedAccount.Agency);
        }
        public void SaveTest()
        {
            var account1 = new Account();
            account1.Number = 2345235;
            account1.Agency = 166;

            var owner = new Person();
            owner.Name = "Ryu Ken";
            owner.Document = "3451345";
            owner.Email = "*****@*****.**";

            account1.Owner = owner;

            account1.Save();

            var account2 = new Account();
            account2.Number = 464567;
            account2.Agency = 345;

            owner.Accounts.Add(account2);

            owner.Save();

            var accountsRepository = new AccountsRepository();

            var accounts = accountsRepository.Find(a => a.PERSON.Id == owner.Id);

            Assert.IsNotNull(accounts);
            Assert.AreEqual(2, accounts.Count);
            Assert.IsTrue(accounts.Contains(account1));
            Assert.IsTrue(accounts.Contains(account2));
        }
        public void FindByPersonNameTest()
        {
            Person createdPerson = new Person();
            createdPerson.Name = "person name test";
            createdPerson.Document = "ZGMFX20A";
            createdPerson.Email = "*****@*****.**";

            PeopleRepository peopleRepository = new PeopleRepository();

            peopleRepository.Save(createdPerson);

            Account createdAccount = new Account();
            createdAccount.Agency = 435;
            createdAccount.Number = 123123123;
            createdAccount.OwnerId = createdPerson.Id;

            AccountsRepository repository = new AccountsRepository();

            repository.Save(createdAccount);

            Assert.AreNotEqual(0, createdAccount.Id);

            Account retrievedAccount = repository.FindSingle(a => a.PERSON.Name == createdPerson.Name);

            Assert.AreEqual(createdAccount, retrievedAccount);
        }
        public void EqualsTest()
        {
            Account account1 = new Account();
            account1.Number = 452356;
            account1.Agency = 567;
            account1.OwnerId = 123;
            account1.Id = 4;

            Account account2 = new Account();
            account2.Number = 452356;
            account2.Agency = 567;
            account2.OwnerId = 123;
            account2.Id = 4;

            Account account3 = new Account();
            account3.Number = 4252356;
            account3.Agency = 567;
            account3.OwnerId = 123;
            account3.Id = 4;

            Account account4 = new Account();
            account4.Number = 452356;
            account4.Agency = 5627;
            account4.OwnerId = 123;
            account4.Id = 4;

            Account account5 = new Account();
            account5.Number = 452356;
            account5.Agency = 567;
            account5.OwnerId = 1223;
            account5.Id = 4;

            Account account6 = new Account();
            account6.Number = 452356;
            account6.Agency = 567;
            account6.OwnerId = 123;
            account6.Id = 42;

            Assert.AreEqual(account1, account1);
            Assert.AreEqual(account2, account1);
            Assert.AreNotEqual(account3, account1);
            Assert.AreNotEqual(account4, account1);
            Assert.AreNotEqual(account5, account1);
            Assert.AreNotEqual(account6, account1);
        }
        public void SaveTest()
        {
            Account account = new Account();
            account.Number = 2345235;
            account.Agency = 166;

            Person owner = new Person();
            owner.Name = "Ryu Ken";
            owner.Document = "3451345";
            owner.Email = "*****@*****.**";

            account.Owner = owner;

            account.Save();

            AccountsRepository accountsRepository = new AccountsRepository();

            Assert.IsNotNull(accountsRepository.FindSingle(a => a.Id == account.Id));
            Assert.IsNotNull(accountsRepository.FindSingle(a => a.PERSON.Name == owner.Name));
            Assert.IsNotNull(accountsRepository.FindSingle(a => a.PERSON.Id == owner.Id));
        }