public void Import_3AccessTypes() { string metadataXml = @" <securityMetadata xmlns=""http://www.re-motion.org/Security/Metadata/1.0""> <classes /> <stateProperties /> <accessTypes> <accessType id=""1d6d25bc-4e85-43ab-a42d-fb5a829c30d5"" name=""Create|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""0"" /> <accessType id=""62dfcd92-a480-4d57-95f1-28c0f5996b3a"" name=""Read|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""1"" /> <accessType id=""11186122-6de0-4194-b434-9979230c41fd"" name=""Edit|Remotion.Security.GeneralAccessTypes, Remotion.Security"" value=""2"" /> </accessTypes> <abstractRoles /> </securityMetadata> "; _importer.Import(GetXmlDocument(metadataXml)); using (_testHelper.Transaction.EnterNonDiscardingScope()) { Assert.AreEqual(0, _importer.Classes.Count, "Class count"); Assert.AreEqual(0, _importer.StateProperties.Count, "State property count"); Assert.AreEqual(0, _importer.AbstractRoles.Count, "Abstract role count"); Assert.AreEqual(3, _importer.AccessTypes.Count, "Access type count"); AccessTypeDefinition expectedAccessType1 = _testHelper.CreateAccessTypeCreate(0); MetadataObjectAssert.AreEqual(expectedAccessType1, _importer.AccessTypes[expectedAccessType1.MetadataItemID], "Access Type Create"); AccessTypeDefinition expectedAccessType2 = _testHelper.CreateAccessTypeRead(1); MetadataObjectAssert.AreEqual(expectedAccessType2, _importer.AccessTypes[expectedAccessType2.MetadataItemID], "Access Type Read"); AccessTypeDefinition expectedAccessType3 = _testHelper.CreateAccessTypeEdit(2); MetadataObjectAssert.AreEqual(expectedAccessType3, _importer.AccessTypes[expectedAccessType3.MetadataItemID], "Access Type Edit"); } }
public void OnCommitting_WithChangedAccessTypeReference_RegistersClassForCommit () { var classDefinition = SecurableClassDefinition.NewObject(); var accessType = _testHelper.CreateAccessTypeCreate (0); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { bool commitOnClassWasCalled = false; classDefinition.Committing += (sender, e) => { commitOnClassWasCalled = true; Assert.That (GetDataContainer ((DomainObject) sender).HasBeenMarkedChanged, Is.True); }; classDefinition.AddAccessType (accessType); ClientTransaction.Current.Commit(); Assert.That (commitOnClassWasCalled, Is.True); } }
public void DeleteFailsIfStateDefinitionIsAssociatedWithStateProperty() { var accessType = _testHelper.CreateAccessTypeCreate(0); var securableClassDefinition = SecurableClassDefinition.NewObject(); securableClassDefinition.AddAccessType(accessType); var messge = "Access type 'Create|Remotion.Security.GeneralAccessTypes, Remotion.Security' " + "cannot be deleted because it is associated with at least one securable class definition."; Assert.That(() => accessType.Delete(), Throws.InvalidOperationException.And.Message.EqualTo(messge)); }