コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void CreateFindUpdateTest()
        {
            Person createdPerson = new Person();
            createdPerson.Name = "gandamu strike freedom";
            createdPerson.Document = "ZGMFX20A";
            createdPerson.Email = "*****@*****.**";

            PeopleRepository repository = new PeopleRepository();

            repository.Save(createdPerson);

            Assert.AreNotEqual(0, createdPerson.Id);

            Person retrievedPerson = repository.FindSingle(p => p.Id == createdPerson.Id);

            Assert.AreEqual(createdPerson, retrievedPerson);

            retrievedPerson.Email = "*****@*****.**";

            repository.Save(retrievedPerson);

            retrievedPerson = repository.FindSingle(p => p.Id == createdPerson.Id);

            Assert.AreEqual("*****@*****.**", retrievedPerson.Email);
        }
コード例 #6
0
        public void EqualsTest()
        {
            Person person1 = new Person();
            person1.Document = "5555";
            person1.Email = "*****@*****.**";
            person1.Name = "Eascn ASd";
            person1.Id = 4;

            Person person2 = new Person();
            person2.Document = "5555";
            person2.Email = "*****@*****.**";
            person2.Name = "Eascn ASd";
            person2.Id = 4;

            Person person3 = new Person();
            person3.Document = "5555 ";
            person3.Email = "*****@*****.**";
            person3.Name = "Eascn ASd";
            person3.Id = 4;

            Person person4 = new Person();
            person4.Document = "5555";
            person4.Email = "ansdklna@ adnjka.com";
            person4.Name = "Eascn ASd";
            person4.Id = 4;

            Person person5 = new Person();
            person5.Document = "5555";
            person5.Email = "*****@*****.**";
            person5.Name = "Eascn ASd ";
            person5.Id = 4;

            Person person6 = new Person();
            person6.Document = "5555";
            person6.Email = "*****@*****.**";
            person6.Name = "Eascn ASd";
            person6.Id = 3;

            Assert.AreEqual(person1, person1);
            Assert.AreEqual(person2, person1);
            Assert.AreNotEqual(person3, person1);
            Assert.AreNotEqual(person4, person1);
            Assert.AreNotEqual(person5, person1);
            Assert.AreNotEqual(person6, person1);
        }
コード例 #7
0
        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));
        }