Example #1
0
        private void CreateStateCombination(StatefulAccessControlList acl, StatePropertyDefinition stateProperty, StateDefinition stateDefinition)
        {
            StateCombination stateCombination = acl.CreateStateCombination();

            stateProperty.AddState(stateDefinition);
            stateCombination.AttachState(stateDefinition);
        }
Example #2
0
        public void AttachState_WithoutClassDefinition()
        {
            StateCombination        combination = StateCombination.NewObject();
            StatePropertyDefinition property    = _testHelper.CreateTestProperty();

            combination.AttachState(property["Test1"]);

            Assert.That(combination.GetStates().Length, Is.EqualTo(1));
        }
Example #3
0
        public void ClearStates()
        {
            SecurableClassDefinition classDefinition = _testHelper.CreateOrderClassDefinition();
            StateCombination         combination     = _testHelper.CreateStateCombination(classDefinition);
            StatePropertyDefinition  property        = _testHelper.CreateTestProperty();

            combination.AttachState(property["Test1"]);
            Assert.That(combination.GetStates(), Is.Not.Empty);

            combination.ClearStates();

            Assert.That(combination.GetStates(), Is.Empty);
        }
Example #4
0
        public void AttachState_NewState()
        {
            SecurableClassDefinition classDefinition = _testHelper.CreateOrderClassDefinition();
            StateCombination         combination     = _testHelper.CreateStateCombination(classDefinition);
            StatePropertyDefinition  property        = _testHelper.CreateTestProperty();

            using (_testHelper.Transaction.CreateSubTransaction().EnterDiscardingScope())
            {
                combination.AttachState(property["Test1"]);

                var states = combination.GetStates();
                Assert.That(states.Length, Is.EqualTo(1));
                Assert.That(states[0], Is.SameAs(property["Test1"]));
            }
        }
Example #5
0
        private StatefulAccessControlList CreateStatefulAcl(SecurableClassDefinition classDefinition, ClientTransaction transaction, params StateDefinition[] states)
        {
            using (transaction.EnterNonDiscardingScope())
            {
                var acl = StatefulAccessControlList.NewObject();
                classDefinition.StatefulAccessControlLists.Add(acl);
                StateCombination stateCombination = acl.CreateStateCombination();

                foreach (StateDefinition state in states)
                {
                    stateCombination.AttachState(state);
                }

                return(acl);
            }
        }