Ejemplo n.º 1
0
        public void LegalSetDefaultOrganizationTest()
        {
            InitAdmins();

            var mainRole  = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch"));
            var mainOrg   = this.GetOrganizationByCodeName("costEngineer");
            var testOrgA  = NewObject <PC.SCOrganization>("测试组织A");
            var testOrgB  = NewObject <PC.SCOrganization>("测试组织B");
            var testUserA = this.NewObject <PC.SCUser>("测试用户A");


            Facade.AddOrganization(testOrgA, mainOrg);
            Facade.AddOrganization(testOrgB, mainOrg);
            Facade.AddUser(testUserA, testOrgA);
            Facade.AddUserToOrganization(testUserA, testOrgB);

            SetContainerMemberAndPermissions(testOrgA, mainRole, new string[] { "UpdateChildren" });
            SetContainerMemberAndPermissions(testOrgB, mainRole, new string[] { "UpdateChildren" });
            SetCurrentPrincipal(this.GetUserByCodeName("wanglch"));

            FacadeWithAcl.SetUserDefaultOrganization(testUserA, testOrgB);

            var actual = PC.Adapters.SchemaRelationObjectAdapter.Instance.Load(testOrgB.ID, testUserA.ID);

            Assert.IsNotNull(actual);

            Assert.AreEqual(actual.Status, SchemaObjectStatus.Normal);

            Assert.AreEqual(actual.Default, true);
        }
Ejemplo n.º 2
0
        public void IllegalSetDefaultOrganizationTest3()
        {
            InitAdmins();

            var mainRole  = this.CreateDefaultRoleWithMembers(this.GetSCUsersByCodeNames("wanglch"));
            var mainOrg   = this.GetOrganizationByCodeName("costEngineer");
            var testOrgA  = NewObject <PC.SCOrganization>("测试组织A");
            var testOrgB  = NewObject <PC.SCOrganization>("测试组织B");
            var testUserA = this.NewObject <PC.SCUser>("测试用户A");


            Facade.AddOrganization(testOrgA, mainOrg);
            Facade.AddOrganization(testOrgB, mainOrg);
            Facade.AddUser(testUserA, testOrgA);
            Facade.AddUserToOrganization(testUserA, testOrgB);

            SetContainerMemberAndPermissions(testOrgB, mainRole, new string[] { "UpdateChildren" });
            SetCurrentPrincipal(this.GetUserByCodeName("wanglch"));

            FacadeWithAcl.SetUserDefaultOrganization(testUserA, testOrgB);

            Assert.Fail("不应执行到此");
        }