Example #1
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 #2
0
        public void ValidateDuringCommit()
        {
            SecurableClassDefinition orderClass      = _testHelper.CreateOrderClassDefinition();
            StatePropertyDefinition  paymentProperty = _testHelper.CreatePaymentStateProperty(orderClass);
            StateDefinition          paidState       = paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name];
            StateDefinition          notPaidState    = paymentProperty[EnumWrapper.Get(PaymentState.None).Name];

            _testHelper.CreateStateCombination(orderClass, paidState);
            _testHelper.CreateStateCombination(orderClass, notPaidState);
            _testHelper.CreateStateCombination(orderClass);
            var dupicateStateCombination = orderClass.CreateStatefulAccessControlList().StateCombinations[0];

            using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope())
            {
                dupicateStateCombination.AttachState(paidState);

                ClientTransaction.Current.Commit();
            }
        }
Example #3
0
        public void Equals_TwoStatelessCombinations()
        {
            SecurableClassDefinition orderClass   = _testHelper.CreateOrderClassDefinition();
            StateCombination         combination1 = _testHelper.CreateStateCombination(orderClass);
            StateCombination         combination2 = _testHelper.CreateStateCombination(orderClass);

            StateCombinationComparer comparer = new StateCombinationComparer();

            Assert.That(comparer.Equals(combination1, combination2), Is.True);
        }