예제 #1
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);
        }
예제 #2
0
        public void MatchesStates_DeliveredAndUnpaid()
        {
            StateCombination combination = _testHelper.GetStateCombinationForDeliveredAndUnpaidOrder();

            StateDefinition[] states = combination.GetStates();

            Assert.That(combination.MatchesStates(states), Is.True);
        }
예제 #3
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));
        }
예제 #4
0
        public void MatchesStates_StatefulWithWildcard()
        {
            StateCombination combination = _testHelper.GetStateCombinationForDeliveredAndUnpaidOrder();

            StateDefinition[] states = combination.GetStates();

            Assert.Fail("TODO: Implement");
            Assert.That(combination.MatchesStates(states), Is.True);
        }
예제 #5
0
        public void GetStates_Empty()
        {
            SecurableClassDefinition classDefinition = _testHelper.CreateOrderClassDefinition();
            StateCombination         combination     = _testHelper.CreateStateCombination(classDefinition);

            StateDefinition[] states = combination.GetStates();

            Assert.That(states.Length, Is.EqualTo(0));
        }
예제 #6
0
        public void GetStates_OneState()
        {
            SecurableClassDefinition classDefinition = _testHelper.CreateOrderClassDefinition();
            StatePropertyDefinition  property        = _testHelper.CreatePaymentStateProperty(classDefinition);
            StateDefinition          state           = property.DefinedStates[1];
            StateCombination         combination     = _testHelper.CreateStateCombination(classDefinition, state);

            StateDefinition[] states = combination.GetStates();

            Assert.That(states.Length, Is.EqualTo(1));
            Assert.That(states[0], Is.SameAs(state));
        }
예제 #7
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"]));
            }
        }
예제 #8
0
        public void GetStates_MultipleStates()
        {
            SecurableClassDefinition classDefinition    = _testHelper.CreateOrderClassDefinition();
            StatePropertyDefinition  paymentProperty    = _testHelper.CreatePaymentStateProperty(classDefinition);
            StateDefinition          paidState          = paymentProperty.DefinedStates[1];
            StatePropertyDefinition  orderStateProperty = _testHelper.CreateOrderStateProperty(classDefinition);
            StateDefinition          deliveredState     = orderStateProperty.DefinedStates[1];
            StateCombination         combination        = _testHelper.CreateStateCombination(classDefinition, paidState, deliveredState);

            StateDefinition[] states = combination.GetStates();

            Assert.That(states.Length, Is.EqualTo(2));
            Assert.That(states, Has.Member(paidState));
            Assert.That(states, Has.Member(deliveredState));
        }
예제 #9
0
        public void CreateStateCombination()
        {
            SecurableClassDefinition  classDefinition = _testHelper.CreateClassDefinition("SecurableClass");
            StatefulAccessControlList acl             = _testHelper.CreateStatefulAcl(classDefinition);

            using (_testHelper.Transaction.CreateSubTransaction().EnterDiscardingScope())
            {
                acl.EnsureDataAvailable();
                Assert.That(acl.State, Is.EqualTo(StateType.Unchanged));

                StateCombination stateCombination = acl.CreateStateCombination();

                Assert.That(stateCombination.AccessControlList, Is.SameAs(acl));
                Assert.That(stateCombination.Class, Is.EqualTo(acl.Class));
                Assert.That(stateCombination.GetStates(), Is.Empty);
                Assert.That(acl.State, Is.EqualTo(StateType.Changed));
            }
        }
예제 #10
0
 private StateDefinition GetStateDefinition(StateCombination stateCombination)
 {
     return(stateCombination.GetStates().SingleOrDefault());
 }