public void TestQuery()
        {
            HierarchyDataManagement page = new HierarchyDataManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IHierarchyApi hierarchyApi = SpringContext.Current.GetObject<IHierarchyApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                HierarchyDataObject obj = new HierarchyDataObject()
                {

                    HierarchyType = "Department",
                    Name = "HierarchyType" + surfix,
                    Description = "HierarchyType" + surfix

                };

                hierarchyApi.Save(obj);
                httpEnv.SetRequestUrl(@"/HierarchyDataDetailPanel/DynamicPage.svc?HierarchyType=Department");

                QueryParameterExpression expression = new QueryParameterExpression("Name", QueryFieldOperators.Equal, "HierarchyType" + surfix);

                SortExpression sort = new SortExpression("Name");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result, "Name"), "HierarchyType" + surfix);
                }
            }
        }
        public void TestQuery()
        {
            UserManagement page = new UserManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IMembershipApi membershipApi = SpringContext.Current.GetObject<IMembershipApi>();
            IPlatformConfiguration platformConfiguration = SpringContext.Current.GetObject<IPlatformConfiguration>();
            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/UserManagement/DynamicPage.svc?Domain=Department");

                #region Create Data
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                UserObject obj = new UserObject()
                {
                    OrganizationId = platformConfiguration.Organization.OrganizationId,
                    Comment = "IT specialist",
                    DisplayName = "Eunge Liu" + surfix,
                    Email = "*****@*****.**",
                    IsApproved = true,
                    MobilePin = "137641855XX",
                    UserName = "******"+surfix
                };
                membershipApi.Save(obj, "password1", null);
                createdObjectIds.Add(obj.UserId);

                #endregion

                #region query
                QueryParameterExpression expression = new QueryParameterExpression("UserName", QueryFieldOperators.Equal, "Eunge" + surfix);

                SortExpression sort = new SortExpression("UserName");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result, "UserName"), "Eunge" + surfix);
                }
                #endregion
            }
        }
        public void TestQuery()
        {
            ConcreteDataManagement page = new ConcreteDataManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IConcreteDataApi concreteDataApi = SpringContext.Current.GetObject<IConcreteDataApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                #region Create Data
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);
                ConcreteDataObject testConcreteData = new ConcreteDataObject()
                {
                    Name = "concrete" + surfix,
                    Value = "concrete" + surfix,
                    Type = "Department",
                    DeleteStatus = DeleteStatus.NotDeleted
                };

                concreteDataApi.Save(testConcreteData);
                ids.Add(testConcreteData.ConcreteDataId);
                #endregion

                httpEnv.SetRequestUrl(@"/ConcreteDataDetailPanel/DynamicPage.svc?ConcreteDataType=Department");

                QueryParameterExpression expression = new QueryParameterExpression("Name", QueryFieldOperators.Equal, "concrete" + surfix);

                SortExpression sort = new SortExpression("Name");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result, "Name"), "concrete" + surfix);
                }
            }
        }
        public void TestQuery()
        {
            OrganizationTypeManagement page = new OrganizationTypeManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/OrganizationTypeManagement/DynamicPage.svc?Domain=Department");
                #region Create Data
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);
                OrganizationTypeObject testOrganizationType = new OrganizationTypeObject()
                {
                    Name = "78903" + surfix,
                    Description = "testOrganizationTypeUpdate" + surfix,
                    Domain = "Department",
                    Predefined = false,
                    DeleteStatus = DeleteStatus.NotDeleted
                };

                organizationApi.Save(testOrganizationType);
                ids.Add(testOrganizationType.OrganizationTypeId);
                #endregion

                QueryParameterExpression expression = new QueryParameterExpression("Name", QueryFieldOperators.Equal, "78903" + surfix);

                SortExpression sort = new SortExpression("Name");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result, "Name"), "78903" + surfix);
                }
            }
        }
        public void TestQuery()
        {
            OrganizationManagement page = new OrganizationManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                #region Create Data
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);
                OrganizationObject testOrganization = new OrganizationObject()
                {
                    OrganizationCode = "78903" + surfix,
                    OrganizationName = "testOrganizationUpdate" + surfix,
                    OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
                    Status = OrganizationStatus.Enabled
                };

                organizationApi.Save(testOrganization);
                createdOrganizationIds.Add(testOrganization.OrganizationId);
                #endregion

                httpEnv.SetRequestUrl(@"/OrganizationManagement/DynamicPage.svc?Domain=Department");

                QueryParameterExpression expression = new QueryParameterExpression("organizationName", QueryFieldOperators.Equal, "testOrganizationUpdate" + surfix);

                SortExpression sort = new SortExpression("organizationName");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result,"organizationName"), "testOrganizationUpdate" + surfix);
                }
            }
        }
 /// <summary>
 /// Compile sorting expression to sort predicate.
 /// </summary>
 /// <param name="sortExpression"></param>
 /// <returns></returns>
 public string CompileSortExpression(SortExpression sortExpression)
 {
     if (sortExpression == null || string.IsNullOrEmpty(sortExpression.FieldName)) return null;
     return string.Format(CultureInfo.InvariantCulture, "{0} {1}", sortExpression.FieldName, sortExpression.Ascending ? "ASC" : "DESC");
 }
        public void TestQuery()
        {
            RoleManagement page = new RoleManagement();

            DynamicPageProxy proxy = new DynamicPageProxy(page);

            IRoleApi roleApi = SpringContext.Current.GetObject<IRoleApi>();

            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            IMembershipApi membershipApi = SpringContext.Current.GetObject<IMembershipApi>();

            IPermissionApi permissionApi = SpringContext.Current.GetObject<IPermissionApi>();

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/RoleManagement/DynamicPage.svc?Domain=Department");
                #region Create Data
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                OrganizationTypeObject obj = new OrganizationTypeObject()
                {
                    Name = "OrganizationTypeTest" + surfix,
                    Description = "OrganizationTypeTest" + surfix,
                    Predefined = false,
                    Domain = "Department",
                    DeleteStatus = DeleteStatus.NotDeleted
                };

                organizationApi.Save(obj);
                OrganizationTypeObjectIds.Add(obj.OrganizationTypeId);

                RoleObject roleObj = new RoleObject()
                {
                    Domain = "Department",
                    RoleName = "superRole" + surfix,
                    Predefined = false
                };

                roleApi.Save(roleObj);

                RoleIds.Add(roleObj.RoleId);
                #endregion

                #region bind query varibles
                QueryParameterExpression expression = new QueryParameterExpression("RoleName", QueryFieldOperators.Equal, "superRole" + surfix);

                SortExpression sort = new SortExpression("RoleName");

                QueryParameter parameters = new QueryParameter()
                {
                    //Expressions = express,
                    PageIndex = 0,
                    PageSize = 10,
                    SortExpression = sort
                };

                parameters.Expressions.Add(expression);

                QueryResults results = proxy.Query(parameters);

                foreach (var result in results.Results)
                {
                    Assert.AreEqual(DataBinder.Eval(result, "RoleName"), "superRole" + surfix);
                }
                #endregion
            }
        }