Exemplo n.º 1
0
        public void Can_Include_Many_Multiple()
        {
            SqlSet <SqlSetInclude.Employee> set1 = db.Table <SqlSetInclude.Employee>()
                                                   .Include("EmployeeTerritories");

            SqlSet <SqlSetInclude.Employee> set2 = set1.Include("Orders");

            SqlSetInclude.Employee item = set1.First();

            Assert.IsNotNull(item.EmployeeTerritories);
            Assert.AreNotEqual(0, item.EmployeeTerritories.Count);
            Assert.IsTrue(item.EmployeeTerritories.All(p => Object.ReferenceEquals(p.Employee, item)));

            // test immutability
            Assert.IsTrue(item.Orders == null || item.Orders.Count == 0);

            item = set2.First();

            Assert.IsNotNull(item.EmployeeTerritories);
            Assert.AreNotEqual(0, item.EmployeeTerritories.Count);
            Assert.IsTrue(item.EmployeeTerritories.All(p => Object.ReferenceEquals(p.Employee, item)));

            Assert.IsNotNull(item.Orders);
            Assert.AreNotEqual(0, item.Orders.Count);
            //Assert.IsTrue(item.Orders.All(p => Object.ReferenceEquals(p.Employee, item)));
        }