public void Commit_TwoStateCombinations() { AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { SecurableClassDefinition orderClass = testHelper.CreateOrderClassDefinition(); StatePropertyDefinition paymentProperty = testHelper.CreatePaymentStateProperty(orderClass); testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.None).Name]); testHelper.Transaction.Commit(); } }
public void ValidateUniqueStateCombinations_TwoStateCombinations() { AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { SecurableClassDefinition orderClass = testHelper.CreateOrderClassDefinition(); StatePropertyDefinition paymentProperty = testHelper.CreatePaymentStateProperty(orderClass); StateCombination paidCombination1 = testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); StateCombination paidCombination2 = testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); testHelper.CreateStateCombination(orderClass, paymentProperty[EnumWrapper.Get(PaymentState.None).Name]); SecurableClassValidationResult result = new SecurableClassValidationResult(); orderClass.ValidateUniqueStateCombinations(result); Assert.That(result.IsValid, Is.False); Assert.That(result.DuplicateStateCombinations.Count, Is.EqualTo(2)); Assert.That(result.DuplicateStateCombinations, Has.Member(paidCombination1)); Assert.That(result.DuplicateStateCombinations, Has.Member(paidCombination2)); } }
public void DuplicateStateCombinations_TwoInvalidStateCombinations() { AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { SecurableClassDefinition orderClass = testHelper.CreateOrderClassDefinition(); StatePropertyDefinition paymentProperty = testHelper.CreatePaymentStateProperty(orderClass); StateCombination statelessCombination = testHelper.CreateStateCombination(orderClass); StateCombination paidStateCombination = testHelper.CreateStateCombination( orderClass, paymentProperty[EnumWrapper.Get(PaymentState.Paid).Name]); SecurableClassValidationResult result = new SecurableClassValidationResult(); result.AddDuplicateStateCombination(statelessCombination); result.AddDuplicateStateCombination(paidStateCombination); Assert.That(result.DuplicateStateCombinations.Count, Is.EqualTo(2)); Assert.That(result.DuplicateStateCombinations, Has.Member(statelessCombination)); Assert.That(result.DuplicateStateCombinations, Has.Member(paidStateCombination)); } }