Example #1
0
        public void Create_One_Lawyer_In_Two_Accounts()
        {
            Customer customer = CreateCustomer(CreatePerson());
            Lawyer   lawyer   = CreateLawyer(CreatePerson());

            Account account1 = AccountTest.CreateAccount();

            account1.Lawyers.Add(lawyer);
            account1.Customers.Add(customer);
            this.context.BankAccounts.Add(account1);

            Account account2 = AccountTest.CreateAccount();

            account2.Lawyers.Add(lawyer);
            this.context.BankAccounts.Add(account2);

            this.context.SaveChanges();

            Assert.True(this.anotherContext.Persons.Count() == 2);
            Assert.True(this.anotherContext.BankAccounts.Count() == 2);
            var lawyers = this.anotherContext.BankAccounts.OfType <Account>().SelectMany(o => o.Lawyers).Distinct().ToList();

            Assert.True(lawyers.Count() == 1);
            Assert.True(this.anotherContext.BankAccounts.OfType <Account>().SelectMany(o => o.Customers).Count() == 1);
        }
Example #2
0
        public void Add_Single_Person_As_Customer_And_Lawyer_2()
        {
            var person   = CreatePerson();
            var lawyer   = Lawyer.CreateLawyer(person, new DateTime(2012, 12, 20));
            var customer = Customer.CreateCustomer(person, "3", 1);

            var account = AccountTest.CreateAccount();

            account.Lawyers.Add(lawyer);
            account.Customers.Add(customer);
            //     Assert.True(this.anotherContext.Accounts.SelectMany(o => o.Lawyers).Distinct().Count() == 1);
            //   Assert.True(this.anotherContext.Accounts.SelectMany(o => o.Customers).Count() == 1);
            // Assert.True(this.anotherContext.Accounts.Count() == 1);
        }
Example #3
0
        public void Add_Single_Person_As_Customer_And_Lawyer()
        {
            var person   = CreatePerson();
            var lawyer   = CreateLawyer(person);
            var customer = CreateCustomer(person);

            var account = AccountTest.CreateAccount();

            account.Lawyers.Add(lawyer);
            account.Customers.Add(customer);

            this.context.BankAccounts.Add(account);
            this.context.SaveChanges();

            Assert.True(this.anotherContext.BankAccounts.OfType <Account>().SelectMany(o => o.Lawyers).Distinct().Count() == 1);
            Assert.True(this.anotherContext.BankAccounts.OfType <Account>().SelectMany(o => o.Customers).Count() == 1);
            Assert.True(this.anotherContext.BankAccounts.Count() == 1);
        }