Beispiel #1
0
        public void SetUp()
        {
            try
            {
                _testHelper = new OrganizationalStructureTestHelper();

                _dbFixtures = new DatabaseFixtures();
                var tenant = _dbFixtures.CreateAndCommitOrganizationalStructureWithTwoTenants(_testHelper.Transaction);

                using (_testHelper.Transaction.EnterNonDiscardingScope())
                {
                    Tenant child = _testHelper.CreateTenant("Child", "UID: TenantChild");
                    child.IsAbstract = true;
                    child.Parent     = tenant;
                    Tenant grandChild = _testHelper.CreateTenant("GrandChild", "UID: TenantGrandChild");
                    grandChild.Parent = child;
                    ClientTransaction.Current.Commit();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #2
0
        private void Build()
        {
            CompanyTenant = _testHelper.CreateTenant("Worldwide Corporation", Guid.NewGuid().ToString());

            HeadPosition   = _testHelper.CreatePosition("Head");
            MemberPosition = _testHelper.CreatePosition("Member");

            DivisionGroupType = _testHelper.CreateGroupType("Division");
            DivisionHead      = _testHelper.CreateGroupTypePosition(DivisionGroupType, HeadPosition);
            DivisionMember    = _testHelper.CreateGroupTypePosition(DivisionGroupType, MemberPosition);
            AustrianDivsion   = CreateGroup("Austria", null, CompanyTenant, DivisionGroupType);
            GermanDivision    = CreateGroup("Germany", null, CompanyTenant, DivisionGroupType);

            DepartmentGroupType = _testHelper.CreateGroupType("Department");
            DepartmentHead      = _testHelper.CreateGroupTypePosition(DepartmentGroupType, HeadPosition);
            DepartmentMember    = _testHelper.CreateGroupTypePosition(DepartmentGroupType, MemberPosition);
            AustrianHumanResourcesDepartment = CreateGroup("Human Resources (Austria)", AustrianDivsion, CompanyTenant, DepartmentGroupType);
            AustrianFinanceDepartment        = CreateGroup("Human Resources (Austria)", AustrianDivsion, CompanyTenant, DepartmentGroupType);
            AustrianProjectsDepartment       = CreateGroup("Projects (Austria)", AustrianDivsion, CompanyTenant, DepartmentGroupType);
            GermanHumanResourcesDepartment   = CreateGroup("Human Resources (Germany)", GermanDivision, CompanyTenant, DepartmentGroupType);

            TeamGroupType          = _testHelper.CreateGroupType("Team");
            TeamHead               = _testHelper.CreateGroupTypePosition(TeamGroupType, HeadPosition);
            TeamMember             = _testHelper.CreateGroupTypePosition(TeamGroupType, MemberPosition);
            AustrianCarTeam        = CreateGroup("Car Developers", AustrianProjectsDepartment, CompanyTenant, TeamGroupType);
            AustrianPlaneTeam      = CreateGroup("Plane Developers", AustrianProjectsDepartment, CompanyTenant, TeamGroupType);
            AustrianAccountingTeam = CreateGroup("Accounts", AustrianFinanceDepartment, CompanyTenant, TeamGroupType);

            OwningGroup = CreateGroup("Users", null, CompanyTenant, null);

            CarTeamMember = CreateUser("CarTeamMember", OwningGroup, CompanyTenant);
            _testHelper.CreateRole(CarTeamMember, AustrianCarTeam, MemberPosition);
        }
Beispiel #3
0
        protected Group CreateGroup()
        {
            Tenant tenant = _testHelper.CreateTenant("TestTenant", "UID: testTenant");
            Group  group  = _testHelper.CreateGroup("TestGroup", "UID: TestGroup", null, tenant);

            return(group);
        }
Beispiel #4
0
        public void InitializeWithOneObjectList_AndDelete()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            testHelper.Transaction.EnterDiscardingScope();
            var list = new ObjectList <BaseSecurityManagerObject> {
                testHelper.CreateTenant("name", "id"), testHelper.CreateTenant("name", "id")
            };

            testHelper.Transaction.CreateSubTransaction().EnterDiscardingScope();

            DomainObjectDeleteHandler deleteHandler = new DomainObjectDeleteHandler(list);

            deleteHandler.Delete();

            Assert.That(deleteHandler.IsDeleted);
            Assert.That(list[0].State, Is.EqualTo(StateType.Deleted));
            Assert.That(list[1].State, Is.EqualTo(StateType.Deleted));
        }
Beispiel #5
0
        public void DeleteGroup_WithRole()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            using (testHelper.Transaction.EnterNonDiscardingScope())
            {
                Tenant   tenant    = testHelper.CreateTenant("TestTenant", "UID: testTenant");
                Group    userGroup = testHelper.CreateGroup("UserGroup", Guid.NewGuid().ToString(), null, tenant);
                Group    roleGroup = testHelper.CreateGroup("RoleGroup", Guid.NewGuid().ToString(), null, tenant);
                User     user      = testHelper.CreateUser("user", "Firstname", "Lastname", "Title", userGroup, tenant);
                Position position  = testHelper.CreatePosition("Position");
                Role     role      = testHelper.CreateRole(user, roleGroup, position);

                roleGroup.Delete();

                Assert.That(role.State, Is.EqualTo(StateType.Invalid));
            }
        }
Beispiel #6
0
        public void Delete_Twice()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            testHelper.Transaction.EnterDiscardingScope();
            var list = new ObjectList <BaseSecurityManagerObject> {
                testHelper.CreateTenant("name", "id")
            };

            testHelper.Transaction.CreateSubTransaction().EnterDiscardingScope();

            DomainObjectDeleteHandler deleteHandler = new DomainObjectDeleteHandler(list);

            deleteHandler.Delete();
            Assert.That(deleteHandler.IsDeleted);

            deleteHandler.Delete();
        }