public void When_doing_a_crm_linq_query_with_an_intersect_entity_and_2_levels_of_joins_and_where_clauses_right_result_is_returned()
        {
            var fakedContext = new XrmFakedContext();
            fakedContext.ProxyTypesAssembly = Assembly.GetExecutingAssembly();

            var parentRole = new Role() { Id = Guid.NewGuid(), Name = "System Administrator" };
            var role = new Role() { Id = Guid.NewGuid(), Name = "Sys Admin" };
            var user = new SystemUser() { Id = Guid.NewGuid(), FirstName = "Jordi" };
            var systemRole = new SystemUserRoles() { Id = Guid.NewGuid() };
            
            

            role["parentroleid"] = parentRole.ToEntityReference();
            systemRole["systemuserid"] = user.ToEntityReference();
            systemRole["roleid"] = role.ToEntityReference();

            
            fakedContext.Initialize(new List<Entity>() {
                user, systemRole, role, parentRole
            });

            var service = fakedContext.GetFakedOrganizationService();

            using (XrmServiceContext ctx = new XrmServiceContext(service))
            {
                var matches = (from sr in ctx.CreateQuery<SystemUserRoles>()
                               join r in ctx.CreateQuery<Role>() on sr.RoleId equals r.RoleId
                               join u in ctx.CreateQuery<SystemUser>() on sr.SystemUserId equals u.SystemUserId

                               where u.FirstName == "Jordi"
                               where r.Name == "Sys Admin"
                               select sr).ToList();

                Assert.True(matches.Count == 1);
            }
        }