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); }
public void MatchesStates_DeliveredAndUnpaid() { StateCombination combination = _testHelper.GetStateCombinationForDeliveredAndUnpaidOrder(); StateDefinition[] states = combination.GetStates(); Assert.That(combination.MatchesStates(states), Is.True); }
public void AttachState_WithoutClassDefinition() { StateCombination combination = StateCombination.NewObject(); StatePropertyDefinition property = _testHelper.CreateTestProperty(); combination.AttachState(property["Test1"]); Assert.That(combination.GetStates().Length, Is.EqualTo(1)); }
public void MatchesStates_StatefulWithWildcard() { StateCombination combination = _testHelper.GetStateCombinationForDeliveredAndUnpaidOrder(); StateDefinition[] states = combination.GetStates(); Assert.Fail("TODO: Implement"); Assert.That(combination.MatchesStates(states), Is.True); }
public void GetStates_Empty() { SecurableClassDefinition classDefinition = _testHelper.CreateOrderClassDefinition(); StateCombination combination = _testHelper.CreateStateCombination(classDefinition); StateDefinition[] states = combination.GetStates(); Assert.That(states.Length, Is.EqualTo(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)); }
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"])); } }
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)); }
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)); } }
private StateDefinition GetStateDefinition(StateCombination stateCombination) { return(stateCombination.GetStates().SingleOrDefault()); }