public void TestCreate()
        {
            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            OrganizationTypeDetailPanel page = new OrganizationTypeDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/OrganizationTypeDetailPanel/DynamicPage.svc?Domain=Department");

                #region bind web control
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                RapidWebDev.UI.Controls.TextBox TextBoxName = new RapidWebDev.UI.Controls.TextBox();
                TextBoxName.Text = "OrganizationTypeTest" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                RapidWebDev.UI.Controls.TextBox TextBoxDescription = new RapidWebDev.UI.Controls.TextBox();
                TextBoxDescription.Text = "OrganizationTypeTest" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                proxy.Set("DropDownListDomain", null);
                #endregion
                string entityId = proxy.Create();

                ids.Add(new Guid(entityId));

                Assert.AreEqual(organizationApi.GetOrganizationType(new Guid(entityId)).Description, "OrganizationTypeTest" + 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 TestCreate()
        {
            OrganizationDetailPanel testpage = new OrganizationDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);

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

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

                #region Setup the pre-required data
                //Setup the right URL
                httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");

                //Binding the required web controls
                TextBox organizationCode = new TextBox();
                organizationCode.Text = "123456" + surfix;
                proxy.Set("TextBoxOrganizationCode", organizationCode);

                TextBox organizationName = new TextBox();
                organizationName.Text = "testOrganization" + surfix;
                proxy.Set("TextBoxOrganizationName", organizationName);

                DropDownList DropDownListOrganizationType = new DropDownList();
                var typeData = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId);

                DropDownListOrganizationType.Items.Clear();
                DropDownListOrganizationType.DataSource = typeData;
                DropDownListOrganizationType.DataBind();
                DropDownListOrganizationType.SelectedIndex = 1;

                proxy.Set("DropDownListOrganizationType", DropDownListOrganizationType);

                Array statusData = new string[] { "Enabled", "Disabled", "Pending" };
                RadioButtonList RadioButtonListOrganizationStatus = new RadioButtonList();
                RadioButtonListOrganizationStatus.DataSource = statusData;
                RadioButtonListOrganizationStatus.DataBind();
                RadioButtonListOrganizationStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListOrganizationStatus", RadioButtonListOrganizationStatus);
                #endregion

                //call the Create Method
                string entityId = proxy.Create();
                //Get the created object
                OrganizationObject organization = organizationApi.GetOrganization(new Guid(entityId));

                Assert.AreEqual(organization.OrganizationName, "testOrganization"+surfix);

                createdOrganizationIds.Add(new Guid(entityId));
            }
        }
        public void TestSave()
        {
            HierarchyDataAggregatePanel page = new HierarchyDataAggregatePanel();

            AggregatePanelPageProxy proxy = new AggregatePanelPageProxy(page);

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/HierarchyDataManagement/DynamicPage.svc?HierarchyType=Area");

                proxy.Save("ShowHierarchyDataTreeView",null);
            }
        }
        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()
        {
            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 TestCreate()
        {
            ConcreteDataDetailPanel page = new ConcreteDataDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            IConcreteDataApi concreteDataApi = SpringContext.Current.GetObject<IConcreteDataApi>();
            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/ConcreteDataDetailPanel/DynamicPage.svc?ConcreteDataType=Department");
                #region Bind Control
                Guid guid = Guid.NewGuid();

                string surfix = guid.ToString().Substring(0, 5);
                TextBox TextBoxName = new TextBox();
                TextBoxName.Text = "concrete" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                TextBox TextBoxValue = new TextBox();
                TextBoxValue.Text = "concrete" + surfix;
                proxy.Set("TextBoxValue", TextBoxValue);

                TextBox TextBoxDescription = new TextBox();
                TextBoxDescription.Text = "concrete" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                Array statusData = new string[] { "NotDeleted", "Deleted" };
                RadioButtonList RadioButtonListStatus = new RadioButtonList();
                RadioButtonListStatus.DataSource = statusData;
                RadioButtonListStatus.DataBind();
                RadioButtonListStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListStatus", RadioButtonListStatus);

                proxy.Set("ExtensionDataForm", null);
                #endregion

                string entityId = proxy.Create();
                ids.Add(new Guid(entityId));

                ConcreteDataObject obj = concreteDataApi.GetById(new Guid(entityId));
                Assert.AreEqual(obj.Name, "concrete" + surfix);

            }
        }
        public void TestCreate()
        {
            HierarchyDataDetailPanel page = new HierarchyDataDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

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

            using (var httpEnv = new HttpEnvironment())
            {
                #region Create Data
                httpEnv.SetRequestUrl(@"/HierarchyDataDetailPanel/DynamicPage.svc?HierarchyType=Department");

                Guid guid = Guid.NewGuid();

                string surfix = guid.ToString().Substring(0, 5);
                W.TextBox TextBoxName = new W.TextBox();
                TextBoxName.Text = "HierarchyType" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                //ComboBox ComboBoxParentHierarchyData = new ComboBox();

                W.TextBox TextBoxDescription = new W.TextBox();
                TextBoxDescription.Text = "HierarchyType" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                proxy.Set("ComboBoxParentHierarchyData", null);

                proxy.Set("ExtensionDataForm",null);
                #endregion

                string entityId = proxy.Create();

                ids.Add(new Guid(entityId));
            }
        }
        public void TestUpdate()
        {
            HierarchyDataDetailPanel page = new HierarchyDataDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

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

            using (var httpEnv = new HttpEnvironment())
            {
                #region Create Data
                httpEnv.SetRequestUrl(@"/HierarchyDataDetailPanel/DynamicPage.svc?HierarchyType=Department");
                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);
                #endregion

                #region Bind Web Control
                W.TextBox TextBoxName = new W.TextBox();
                TextBoxName.Text = "HierarchyType" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                W.TextBox TextBoxDescription = new W.TextBox();
                TextBoxDescription.Text = "HierarchyTypeUpdate" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                proxy.Set("ComboBoxParentHierarchyData", null);

                proxy.Set("ExtensionDataForm", null);
                #endregion

                proxy.Update(obj.HierarchyDataId.ToString());

                Assert.AreEqual(obj.Description, "HierarchyType" + surfix);

                obj = hierarchyApi.GetHierarchyData(obj.HierarchyDataId);

                Assert.AreEqual(obj.Description, "HierarchyTypeUpdate" + surfix);

            }
        }
        public void TestUpdate()
        {
            OrganizationDetailPanel testpage = new OrganizationDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);

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

            Guid guid = Guid.NewGuid();

            string surfix = guid.ToString().Substring(0, 5);

            using (var httpEnv = new HttpEnvironment())
            {
                #region Setup the pre-required data
                //Setup the right URL
                httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");

                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

                OrganizationObject organization = organizationApi.GetOrganizationByName("testOrganizationUpdate"+surfix);

                #region Setup the Updated Code
                //Binding the required web controls
                TextBox organizationCode = new TextBox();
                organizationCode.Text = "78903" + surfix;
                proxy.Set("TextBoxOrganizationCode", organizationCode);

                TextBox organizationName = new TextBox();
                organizationName.Text = "OrganziationTest" + surfix;
                proxy.Set("TextBoxOrganizationName", organizationName);

                DropDownList DropDownListOrganizationType = new DropDownList();
                var typeData = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId);

                DropDownListOrganizationType.Items.Clear();
                DropDownListOrganizationType.DataSource = typeData;
                DropDownListOrganizationType.DataBind();
                DropDownListOrganizationType.SelectedIndex = 1;

                proxy.Set("DropDownListOrganizationType", DropDownListOrganizationType);

                Array statusData = new string[] { "Enabled", "Disabled", "Pending" };
                RadioButtonList RadioButtonListOrganizationStatus = new RadioButtonList();
                RadioButtonListOrganizationStatus.DataSource = statusData;
                RadioButtonListOrganizationStatus.DataBind();
                RadioButtonListOrganizationStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListOrganizationStatus", RadioButtonListOrganizationStatus);
                #endregion
                proxy.Update(organization.OrganizationId.ToString());

                OrganizationObject organizationUpdated = organizationApi.GetOrganization(organization.OrganizationId);

                Assert.AreNotEqual(organizationUpdated.OrganizationName, "testOrganization" + surfix);
                Assert.AreEqual(organizationUpdated.OrganizationName, "OrganziationTest" + surfix);
            }
        }
        public void TestCreate()
        {
            UserDetailPanel page = new UserDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

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

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/UserDetailPanel/DynamicPage.svc?Domain=Department");

                #region bind web control
                Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);

                OrganizationSelector OrganizationSelector = new OrganizationSelector();
                //IList<OrganizationObject> ds = new List<OrganizationObject>();
                OrganizationObject organization = new OrganizationObject()
                {
                    OrganizationCode = "123456" + surfix,
                    OrganizationName = "org" + surfix,
                    Status = OrganizationStatus.Enabled,
                    OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
                    Description = "organ"
                };

                organizationApi.Save(organization);
                //ds.Add(organization);
                createdOrganizationIds.Add(organization.OrganizationId);

                OrganizationSelector.SelectedOrganization = organization;

                proxy.Set("OrganizationSelector", OrganizationSelector);

                TextBox TextBoxUserName = new TextBox();
                TextBoxUserName.Text = "Eunge" + surfix;
                proxy.Set("TextBoxUserName", TextBoxUserName);

                TextBox TextBoxPassword = new TextBox();
                TextBoxPassword.Text = "Password" + surfix;
                proxy.Set("TextBoxPassword", TextBoxPassword);

                TextBox TextBoxConfirmPassword = new TextBox();
                TextBoxConfirmPassword.Text = "Password" + surfix;
                proxy.Set("TextBoxConfirmPassword", TextBoxConfirmPassword);

                TextBox TextBoxDisplayName = new TextBox();
                TextBoxDisplayName.Text = "Eunge" + surfix;
                proxy.Set("TextBoxDisplayName", TextBoxConfirmPassword);

                TextBox TextBoxEmail = new TextBox();
                TextBoxEmail.Text = "*****@*****.**";
                proxy.Set("TextBoxEmail", TextBoxEmail);

                TextBox TextBoxMobile = new TextBox();
                TextBoxMobile.Text = "13456789009";
                proxy.Set("TextBoxMobile", TextBoxMobile);

                ExtensionDataForm UserExtensionDataForm = null;
                proxy.Set("UserExtensionDataForm", UserExtensionDataForm);

                TextBox TextBoxComment = new TextBox();
                TextBoxComment.Text = "13456789009" + surfix;
                proxy.Set("TextBoxComment", TextBoxComment);

                Array statusData = new string[] { "true", "false" };
                RadioButtonList RadioButtonListStatus = new RadioButtonList();
                RadioButtonListStatus.DataSource = statusData;
                RadioButtonListStatus.DataBind();
                RadioButtonListStatus.SelectedIndex = 0;
                proxy.Set("RadioButtonListStatus", RadioButtonListStatus);

                TextBox TextBoxCreationDate = new TextBox();
                TextBoxCreationDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxCreationDate", TextBoxCreationDate);

                TextBox TextBoxLastLoginDate = new TextBox();
                TextBoxLastLoginDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastLoginDate", TextBoxLastLoginDate);

                TextBox TextBoxLastActivityDate = new TextBox();
                TextBoxLastActivityDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastActivityDate", TextBoxLastActivityDate);

                TextBox TextBoxLockedOutDate = new TextBox();
                TextBoxLockedOutDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLockedOutDate", TextBoxLockedOutDate);

                TextBox TextBoxLastPasswordChangedDate = new TextBox();
                TextBoxLastPasswordChangedDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastPasswordChangedDate", TextBoxLastPasswordChangedDate);

                TextBox TextBoxLastUpdatedDate = new TextBox();
                TextBoxLastUpdatedDate.Text = System.DateTime.UtcNow.ToShortTimeString();
                proxy.Set("TextBoxLastUpdatedDate", TextBoxLastUpdatedDate);

                PermissionTreeView @PermissionTreeView = null;
                proxy.Set("PermissionTreeView", @PermissionTreeView);

                #endregion
                string entity = proxy.Create();
                createdObjectIds.Add(new Guid(entity));

            }
        }
        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);
                }
            }
        }
        public void TestUpdate()
        {
            IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();

            OrganizationTypeDetailPanel page = new OrganizationTypeDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/OrganizationTypeDetailPanel/DynamicPage.svc?Domain=Department");

                #region Create Data
                 Guid guid = Guid.NewGuid();
                string surfix = guid.ToString().Substring(0, 5);
                OrganizationTypeObject obj = new OrganizationTypeObject()
                {
                    Name = "OrganizationTypeTestUpdate" + surfix,
                    Description = "OrganizationTypeTest" + surfix,
                    Predefined = false,
                    Domain = "Department",
                    DeleteStatus = DeleteStatus.NotDeleted
                };

                organizationApi.Save(obj);

                ids.Add(obj.OrganizationTypeId);
                #endregion
                #region Bind Web Control

                RapidWebDev.UI.Controls.TextBox TextBoxName = new RapidWebDev.UI.Controls.TextBox();
                TextBoxName.Text = "OrganizationTypeTestUpdate" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                RapidWebDev.UI.Controls.TextBox TextBoxDescription = new RapidWebDev.UI.Controls.TextBox();
                TextBoxDescription.Text = "OrganizationTypeTestUpdate" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                DropDownList DropDownListDomain = new DropDownList();
                var typeData = new string[] { "Department" };
                DropDownListDomain.DataSource = typeData;
                DropDownListDomain.DataBind();
                DropDownListDomain.SelectedIndex = 0;
                proxy.Set("DropDownListDomain", DropDownListDomain);

                #endregion

                proxy.Update(obj.OrganizationTypeId.ToString());

                Assert.AreEqual(obj.Description, "OrganizationTypeTest" + surfix);

                obj = organizationApi.GetOrganizationType(obj.OrganizationTypeId);

                Assert.AreEqual(obj.Description, "OrganizationTypeTestUpdate" + surfix);

            }
        }
        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
            }
        }
        public void TestCreate()
        {
            IRoleApi roleApi = SpringContext.Current.GetObject<IRoleApi>();

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

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

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

            RoleDetailPanel page = new RoleDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(page);

            using (var httpEnv = new HttpEnvironment())
            {
                httpEnv.SetRequestUrl(@"/RoleDetailPanel/DynamicPage.svc?Domain=Department");
                UserObject current = membershipApi.Get("admin");
                httpEnv.SetSessionParaemeter("CurrentUser", current);

                #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);

                #endregion

                #region bind web control

                PermissionTreeView permissionTreeView = new PermissionTreeView();
                proxy.Set("PermissionTreeView", permissionTreeView);
                Type _type = typeof(PermissionTreeView);
                _type.GetMethod("OnInit", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(permissionTreeView, new object[] { new EventArgs() });
                IList<string> values = new List<string>();

                IList<PermissionConfig> permissions = permissionApi.FindPermissionConfig(current.UserId).ToList<PermissionConfig>();
                for (int i = 0; i < permissions.Count; i++)
                {
                    if ((permissions[i].Value == null) || (permissions[i].Value.Equals(String.Empty)))
                        values.Add("P"+i);
                    else
                        values.Add(permissions[i].Value);
                }
                permissionTreeView.CheckedValues = values;

                TextBox TextBoxName = new TextBox();
                TextBoxName.Text = "SuperRole" + surfix;
                proxy.Set("TextBoxName", TextBoxName);

                TextBox TextBoxDescription = new TextBox();
                TextBoxDescription.Text = "SuperRole" + surfix;
                proxy.Set("TextBoxDescription", TextBoxDescription);

                #endregion

                string entityId = proxy.Create();
                RoleIds.Add(new Guid(entityId));

            }
        }
        public void TestLoadWritableEntity()
        {
            OrganizationDetailPanel testpage = new OrganizationDetailPanel();

            DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);

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

            Guid guid = Guid.NewGuid();

            string surfix = guid.ToString().Substring(0, 5);

            using (var httpEnv = new HttpEnvironment())
            {
                #region Setup the pre-required data
                //Setup the right URL
                httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");

                OrganizationObject testOrganization = new OrganizationObject()
                {
                    OrganizationCode = "78901" + surfix,
                    OrganizationName = "testOrganization1" + surfix,
                    OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
                    Status = OrganizationStatus.Enabled
                };
                organizationApi.Save(testOrganization);

                #endregion

                OrganizationObject organization = organizationApi.GetOrganizationByName("testOrganization1" + surfix);

                proxy.LoadWritableEntity(organization.OrganizationId.ToString());

                Assert.AreEqual(organization.OrganizationName, ((TextBox)proxy.Get("TextBoxOrganizationName")).Text);

                createdOrganizationIds.Add(testOrganization.OrganizationId);
            }
        }