public void OnCommitting_WithChangedStatePropertyReference_RegistersClassForCommit() { var classDefinition = SecurableClassDefinition.NewObject(); var stateProperty = _testHelper.CreateFileStateProperty(0); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { bool commitOnClassWasCalled = false; classDefinition.Committing += (sender, e) => { commitOnClassWasCalled = true; Assert.That(GetDataContainer((DomainObject)sender).HasBeenMarkedChanged, Is.True); }; classDefinition.AddStateProperty(stateProperty); ClientTransaction.Current.Commit(); Assert.That(commitOnClassWasCalled, Is.True); } }
public void Import_2StateProperties() { string metadataXml = @" <securityMetadata xmlns=""http://www.re-motion.org/Security/Metadata/1.0""> <classes /> <stateProperties> <stateProperty id=""00000000-0000-0000-0002-000000000001"" name=""State""> <state name=""New"" value=""0"" /> <state name=""Normal"" value=""1"" /> <state name=""Archived"" value=""2"" /> </stateProperty> <stateProperty id=""00000000-0000-0000-0001-000000000001"" name=""Confidentiality""> <state name=""Normal"" value=""0"" /> <state name=""Confidential"" value=""1"" /> <state name=""Private"" value=""2"" /> </stateProperty> </stateProperties> <accessTypes /> <abstractRoles /> </securityMetadata> "; _importer.Import(GetXmlDocument(metadataXml)); using (_testHelper.Transaction.EnterNonDiscardingScope()) { Assert.AreEqual(0, _importer.Classes.Count, "Class count"); Assert.AreEqual(2, _importer.StateProperties.Count, "State property count"); Assert.AreEqual(0, _importer.AbstractRoles.Count, "Abstract role count"); Assert.AreEqual(0, _importer.AccessTypes.Count, "Access type count"); StatePropertyDefinition expectedProperty1 = _testHelper.CreateFileStateProperty(0); StatePropertyDefinition actualProperty1 = _importer.StateProperties[expectedProperty1.MetadataItemID]; Assert.IsNotNull(actualProperty1, "State property not found"); MetadataObjectAssert.AreEqual(expectedProperty1, actualProperty1, "State property"); StatePropertyDefinition expectedProperty2 = _testHelper.CreateConfidentialityProperty(1); StatePropertyDefinition actualProperty2 = _importer.StateProperties[expectedProperty2.MetadataItemID]; Assert.IsNotNull(actualProperty2, "Confidentiality property not found"); MetadataObjectAssert.AreEqual(expectedProperty2, actualProperty2, "Confidentiality property"); } }