Пример #1
0
        public void GetState_ValidName()
        {
            StatePropertyDefinition stateProperty = _testHelper.CreateConfidentialityProperty(0);

            StateDefinition actualState = stateProperty.GetState(MetadataTestHelper.Confidentiality_ConfidentialName);

            StateDefinition expectedState = _testHelper.CreateConfidentialState();

            MetadataObjectAssert.AreEqual(expectedState, actualState, "Confidential state");
        }
Пример #2
0
        public void DeleteFailsIfStateDefinitionIsAssociatedWithStateProperty()
        {
            var property = _testHelper.CreateConfidentialityProperty(0);
            var state    = property["Private"];

            var messge = "State 'Private' cannot be deleted because it is associated with state property 'Confidentiality'.";

            Assert.That(() => state.Delete(), Throws.InvalidOperationException.And.Message.EqualTo(messge));
        }
Пример #3
0
        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");
            }
        }