Exemplo n.º 1
0
        public void TestAddCondition_CreateNewCondition()
        {
            //set up environment
            IPolicy policy = PolicyFactory.CreatePolicy("TestPolicy", m_policySet, PolicyStatus.Active, "None");
            IConditionGroup rootConditionGroup = (IConditionGroup)policy.Conditions[0];
            DynamicMock conditionsResourceSelectForm = new DynamicMock(typeof(IConditionsResourceSelectorForm));

            //set up test object
            AddConditionState state1 = new AddConditionStateTester();
            state1.Policy = policy;
            state1.StateMachine = (IStateMachine)m_stateMachine.MockInstance;
            state1.ConditionGroup = rootConditionGroup;
            //state1.ConditionMethodDisplay = new ConditionDisplayContentInFileContext();
            state1.Source = AddConditionState.ConditionSource.New;
            state1.SelectionUI = conditionsResourceSelectForm.MockInstance;

            IPolicyObjectCollection<IPolicyObject> selectedConditions = new PolicyObjectCollection<IPolicyObject>();
            ICondition condition1 = ConditionUnitFactory.CreateCondition(ConditionUnitFactory.PreDefinedConditionType.ContentInFileContext);
            selectedConditions.Add(condition1);
            conditionsResourceSelectForm.ExpectAndReturn("get_SelectedConditions", selectedConditions, new object[0]);

            //test conditions group is empty
            Assert.AreEqual(0, rootConditionGroup.Conditions.Count, "Unexpected number of conditions in conditionGroup.Conditions");

            //add new condition
            IState showConditionsState = new ShowConditionsState();
            m_stateMachine.ExpectAndReturn("GetState", showConditionsState, StateTypeEnum.ShowConditions);
            m_stateMachine.Expect("SetState", showConditionsState);
            state1.Enter();

            //test condition group
            Assert.AreEqual(1, rootConditionGroup.Conditions.Count, "Unexpected number of conditions in conditionGroup.Conditions");

            //test condition
            ICondition condition = rootConditionGroup.Conditions[0] as ICondition;
            Assert.IsNotNull(condition, "unexpected object type in condition");
            Assert.AreSame(rootConditionGroup, condition.Parent, "Unexpected object in condition.Parent");
            Assert.AreEqual("", condition.Name.Value, "unexpected condition name");
            Assert.AreEqual(OperatorType.GreaterThan, condition.Operator, "unexpected name in condition");
            Assert.AreEqual("IDataLengthComparer", condition.Class, "unexpected class in condition");
            Assert.AreEqual(Guid.Empty, condition["Ignore"].Identifier, "unexpected identifier on Ignore attribute on condition");
            Assert.AreEqual(Boolean.FalseString, condition["Ignore"].Value, "unexpected value on Ignore attribute on condition");

            //condition.dataleft
            IDataElement dataElement = condition.DataLeft as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataleft");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition.dataleft");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected display name in condition.dataleft");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataleft");
            Assert.AreEqual("contentInFileContext", dataElement.Name.Value, "unexpected name in condition.dataleft");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataleft");
            Assert.AreEqual(DataType.Object, dataElement.Type, "unexpected type in condition.dataleft");

            //condition.dataleft.data 
            IDataSource dataSource = dataElement.Data as IDataSource;
            Assert.IsNotNull(dataSource, "unexpected object type in condition.dataleft.data");
            Assert.AreEqual("Workshare.Policy.Condition.ContentAnalysis.dll", dataSource.Assembly, "unexpected assembly in condition.dataleft.data");
            Assert.AreEqual("Workshare.Policy.Condition.ContentAnalysis", dataSource.Class, "unexpected class in condition.dataleft.data");
            Assert.AreEqual(Guid.Empty, dataSource.Name.Identifier, "unexpected name identifier in condition.dataleft.data");
            Assert.AreEqual("Workshare.Policy.Condition.ContentAnalysis", dataSource.Name.Value, "unexpected name in condition.dataleft.data");

            //condition.dataleft.data.method 
            IDataMethod dataMethod = dataSource.Method as IDataMethod;
            Assert.IsNotNull(dataMethod, "unexpected object type in condition.dataleft.data.method");
            Assert.AreEqual(Guid.Empty, dataMethod.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method");
            Assert.AreEqual("TextLookupInFileType", dataMethod.Name.Value, "unexpected name in condition.dataleft.data.method");
            Assert.AreEqual(5, dataMethod.Parameters.Count, "unexpected number of parameters in condition.dataleft.data.method");

            //condition.dataleft.data.method.parameters[0]
            IParameter parameter = dataMethod.Parameters[0];
            Assert.AreEqual(Guid.Empty, parameter.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[0]");
            Assert.AreEqual("file", parameter.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[0]");

            //condition.dataleft.data.method.parameters[0].value
            dataElement = dataMethod.Parameters[0].Value as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual("file", dataElement.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected displayname in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(DataType.Object, dataElement.Type, "unexpected datatype in condition.dataleft.data.method.parameters[0].value");

            //condition.dataleft.data.method.parameters[0].value.data
            dataSource = dataElement.Data as IDataSource;
            Assert.IsNotNull(dataSource, "unexpected object type in condition.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual("this", dataSource.Assembly, "unexpected assembly in condition.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual("this", dataSource.Class, "unexpected class in condition.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual(Guid.Empty, dataSource.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual("this", dataSource.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[0].value.data");

            //condition.dataleft.data.method.parameters[0].value.data.method
            IDataMethod fileDataMethod = dataSource.Method as IDataMethod;
            Assert.IsNotNull(fileDataMethod, "unexpected object type in condition.dataleft.data.method.parameters[0].value.data.method");
            Assert.AreEqual(Guid.Empty, fileDataMethod.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[0].value.data.method");
            Assert.AreEqual("CurrentFile", fileDataMethod.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[0].value.data.method");
            Assert.AreEqual(0, fileDataMethod.Parameters.Count, "unexpected number of parameters in condition.dataleft.data.method.parameters[0].value.data.method");

            //condition1copy.dataleft.data.method.parameters[1]
            parameter = dataMethod.Parameters[1];
            Assert.AreEqual(Guid.Empty, parameter.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[1]");
            Assert.AreEqual("fileTypes", parameter.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[1]");

            //condition1copy.dataleft.data.method.parameters[1].value
            dataElement = dataMethod.Parameters[1].Value as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual("fileTypes", dataElement.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected displayname in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(DataType.StringArray, dataElement.Type, "unexpected datatype in condition1copy.dataleft.data.method.parameters[1].value");

            //condition.dataleft.data.method.parameters[1].value.data
            IPolicyObjectCollection<IDataItem> collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collection, "unexpected object type in condition.dataleft.data.method.parameters[1].value.data");
            Assert.AreEqual(5, collection.Count, "unexpected number of items in condition.dataleft.data.method.parameters[1].value.data");

            //condition.dataleft.data.method.parameters[1].value.data[0]
            IDataItem dataItem = collection[0] as IDataItem;
            Assert.IsNotNull(dataItem, "unexpected object type in condition.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(Guid.Empty, dataItem.Name.Identifier, "unexpected displayname identifier in condition.dataleft.data.method.parameters[1].value");
            Assert.AreEqual("", dataItem.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(false, dataItem.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocument), dataItem.Value, "unexpected value in condition.dataleft.data.method.parameters[1].value.data[0]");

            //condition.dataleft.data.method.parameters[2]
            parameter = dataMethod.Parameters[2];
            Assert.AreEqual(Guid.Empty, parameter.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[2]");
            Assert.AreEqual("content", parameter.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[2]");

            //condition.dataleft.data.method.parameters[2].value
            dataElement = dataMethod.Parameters[2].Value as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual("content", dataElement.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual("word or phrase", dataElement.DisplayName.Value, "unexpected displayname in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(DataType.StringArray, dataElement.Type, "unexpected datatype in condition.dataleft.data.method.parameters[2].value");

            //condition.dataleft.data.method.parameters[2].value.data
            collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collection, "unexpected object type in condition.dataleft.data.method.parameters[2].value.data");
            Assert.AreEqual(0, collection.Count, "unexpected number of items in condition.dataleft.data.method.parameters[2].value.data");

            //condition.dataleft.data.method.parameters[3]
            parameter = dataMethod.Parameters[3];
            Assert.AreEqual(Guid.Empty, parameter.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[3]");
            Assert.AreEqual("context", parameter.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[3]");

            //condition.dataleft.data.method.parameters[3].value
            dataElement = dataMethod.Parameters[3].Value as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual("context", dataElement.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected displayname in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(DataType.StringArray, dataElement.Type, "unexpected datatype in condition.dataleft.data.method.parameters[3].value");

            //condition.dataleft.data.method.parameters[3].value.data
            collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collection, "unexpected object type in condition.dataleft.data.method.parameters[3].value.data");
            Assert.AreEqual(1, collection.Count, "unexpected number of items in condition.dataleft.data.method.parameters[3].value.data");

            //condition.dataleft.data.method.parameters[3].value.data[0]
            dataItem = collection[0] as IDataItem;
            Assert.IsNotNull(dataItem, "unexpected object type in condition.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(Guid.Empty, dataItem.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual("", dataItem.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(false, dataItem.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual("Paragraph", dataItem.Value, "unexpected value in condition.dataleft.data.method.parameters[3].value.data[0]");

            //condition.dataleft.data.method.parameters[4].value
            dataElement = dataMethod.Parameters[4].Value as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual("matchWholeWords", dataElement.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual(Guid.Empty, dataElement.DisplayName.Identifier, "unexpected displayname identifier in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected displayname in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[4].value");
            Assert.AreEqual(DataType.BooleanArray, dataElement.Type, "unexpected datatype in condition.dataleft.data.method.parameters[4].value");

            //condition.dataleft.data.method.parameters[4].value.data
            collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collection, "unexpected object type in condition.dataleft.data.method.parameters[4].value.data");
            Assert.AreEqual(1, collection.Count, "unexpected number of items in condition.dataleft.data.method.parameters[4].value.data");

            //condition.dataleft.data.method.parameters[4].value.data[0]
            dataItem = collection[0] as IDataItem;
            Assert.IsNotNull(dataItem, "unexpected object type in condition.dataleft.data.method.parameters[4].value.data[0]");
            Assert.AreEqual(Guid.Empty, dataItem.Name.Identifier, "unexpected name identifier in condition.dataleft.data.method.parameters[4].value.data[0]");
            Assert.AreEqual("", dataItem.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[4].value.data[0]");
            Assert.AreEqual(false, dataItem.ReadOnly, "unexpected readonly in condition.dataleft.data.method.parameters[4].value.data[0]");
            Assert.AreEqual(true, dataItem.Value, "unexpected value in condition.dataleft.data.method.parameters[4].value.data[0]");

            //condition.dataright
            dataElement = condition.DataRight as IDataElement;
            Assert.IsNotNull(dataElement, "unexpected object type in condition.dataright");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataright");
            Assert.AreEqual("", dataElement.DisplayName.Value, "unexpected display name in condition.dataright");
            Assert.AreEqual(Guid.Empty, dataElement.Name.Identifier, "unexpected name identifier in condition.dataright");
            Assert.AreEqual("numberOfOccurrences", dataElement.Name.Value, "unexpected name in condition.dataright");
            Assert.AreEqual(false, dataElement.ReadOnly, "unexpected readonly in condition.dataright");
            Assert.AreEqual(DataType.Long, dataElement.Type, "unexpected type in condition.dataright");

            //condition.dataright.data
            dataItem = dataElement.Data as IDataItem;
            Assert.IsNotNull(dataItem, "unexpected object type in condition.dataright.data");
            Assert.AreEqual(Guid.Empty, dataItem.Name.Identifier, "unexpected name identifier in condition.dataright.data");
            Assert.AreEqual("", dataItem.Name.Value, "unexpected name in condition.dataright.data");
            Assert.AreEqual(false, dataItem.ReadOnly, "unexpected readonly in condition.dataright.data");
            Assert.AreEqual(0, dataItem.Value, "unexpected value in condition.dataright");

            //test state machine state
            m_stateMachine.Verify();
            conditionsResourceSelectForm.Verify();

            //set up another test object
            AddConditionState state2 = new AddConditionStateTester();
            state2.Policy = policy;
            state2.StateMachine = (IStateMachine)m_stateMachine.MockInstance;
            state2.ConditionGroup = rootConditionGroup;
            //state2.ConditionMethodDisplay = new ConditionDisplayFileSize();
            state2.SelectionUI = conditionsResourceSelectForm.MockInstance;
            state2.Source = AddConditionState.ConditionSource.New;

            condition1 = ConditionUnitFactory.CreateCondition(ConditionUnitFactory.PreDefinedConditionType.FileSize);
            selectedConditions.Add(condition1);
            conditionsResourceSelectForm.ExpectAndReturn("get_SelectedConditions", selectedConditions, new object[0]);

            //add another new condition
            m_stateMachine.ExpectAndReturn("GetState", showConditionsState, StateTypeEnum.ShowConditions);
            m_stateMachine.Expect("SetState", showConditionsState);
            state2.Enter();

            //test condition group
            Assert.AreEqual(2, rootConditionGroup.Conditions.Count, "Unexpected number of conditions in conditionGroup.Conditions");

            //test condition
            ICondition condition2 = rootConditionGroup.Conditions[1] as ICondition;
            Assert.IsNotNull(condition2, "Unexpected object type in condition");
            Assert.AreSame(rootConditionGroup, condition2.Parent, "Unexpected object in condition.Parent");

            //test state machine state
            m_stateMachine.Verify();
            conditionsResourceSelectForm.Verify();
        }
Exemplo n.º 2
0
        public void TestAddCondition_AddFromCatalogue()
        {
            //set up environment
            IPolicy policy = PolicyFactory.CreatePolicy("TestPolicy", m_policySet, PolicyStatus.Active, "None");
            IConditionGroup rootConditionGroup = (IConditionGroup)policy.Conditions[0];
            DynamicMock conditionsCatalogueSelectForm = new DynamicMock(typeof(IConditionsCatalogueSelectorForm));

            //set up test object
            AddConditionState state = new AddConditionStateTester();
            state.Policy = policy;
            state.StateMachine = (IStateMachine)m_stateMachine.MockInstance;
            state.ConditionGroup = rootConditionGroup;
            //state.ConditionMethodDisplay = null;
            state.Source = AddConditionState.ConditionSource.FromCatalogue;
            state.SelectionUI = conditionsCatalogueSelectForm.MockInstance;

            //test conditions group is empty
            Assert.AreEqual(0, rootConditionGroup.Conditions.Count, "Unexpected number of conditions in conditionGroup.Conditions");

            //add new condition
            IState showConditionsState = new ShowConditionsState();
            m_stateMachine.ExpectAndReturn("GetState", showConditionsState, StateTypeEnum.ShowConditions);
            m_stateMachine.Expect("SetState", showConditionsState);

            IPolicyObjectCollection<IPolicyObject> selectedConditions = new PolicyObjectCollection<IPolicyObject>();
            ICondition condition1 = ConditionUnitFactory.CreateCondition(ConditionUnitFactory.PreDefinedConditionType.ContentInFileContext);
            ICondition condition2 = ConditionUnitFactory.CreateCondition(ConditionUnitFactory.PreDefinedConditionType.ContentInFileName);
            ICondition condition3 = ConditionUnitFactory.CreateCondition(ConditionUnitFactory.PreDefinedConditionType.FileSize);
            selectedConditions.Add(condition1);
            selectedConditions.Add(condition2);
            selectedConditions.Add(condition3);
            conditionsCatalogueSelectForm.ExpectAndReturn("get_SelectedConditions", selectedConditions, new object[0]);

            state.Enter();

            //test root condition group
            Assert.AreEqual(3, rootConditionGroup.Conditions.Count, "Unexpected number of conditions in conditionGroup.Conditions");

            //test conditions
            ICondition condition1Copy = rootConditionGroup.Conditions[0] as ICondition;
            ICondition condition2Copy = rootConditionGroup.Conditions[1] as ICondition;
            ICondition condition3Copy = rootConditionGroup.Conditions[2] as ICondition;

            //condition1
            Assert.IsNotNull(condition1Copy, "unexpected object type in condition");
            Assert.AreEqual(condition1.Name.Value, condition1Copy.Name.Value, "unexpected condition name");
            Assert.AreEqual(condition1.Operator, condition1Copy.Operator, "unexpected name in condition");
            Assert.AreEqual(condition1.Class, condition1Copy.Class, "unexpected class in condition");
            Assert.AreEqual(condition1["preDefinedConditionType"].Identifier, condition1Copy["preDefinedConditionType"].Identifier, "unexpected pre-defined condition type");
            Assert.AreEqual(condition1["preDefinedConditionType"].Value, condition1Copy["preDefinedConditionType"].Value, "unexpected pre-defined condition type");
            Assert.AreEqual(condition1["Ignore"].Identifier, condition1Copy["Ignore"].Identifier, "unexpected identifier on Ignore attribute on condition1");
            Assert.AreEqual(condition1["Ignore"].Value, condition1Copy["Ignore"].Value, "unexpected value on Ignore attribute on condition1");

            //condition1copy.dataleft
            IDataElement dataLeft = condition1.DataLeft as IDataElement;
            IDataElement dataLeftCopy = condition1Copy.DataLeft as IDataElement;
            Assert.AreEqual(dataLeft.DisplayName.Identifier, dataLeftCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft");
            Assert.AreEqual(dataLeft.DisplayName.Value, dataLeftCopy.DisplayName.Value, "unexpected display name in condition1copy.dataleft");
            Assert.AreEqual(dataLeft.Name.Identifier, dataLeftCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft");
            Assert.AreEqual(dataLeft.Name.Value, dataLeftCopy.Name.Value, "unexpected name in condition1copy.dataleft");
            Assert.AreEqual(dataLeft.ReadOnly, dataLeftCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft");
            Assert.AreEqual(dataLeft.Type, dataLeftCopy.Type, "unexpected type in condition1copy.dataleft");

            //condition1copy.dataleft.data 
            IDataSource dataSource = dataLeft.Data as IDataSource;
            IDataSource dataSourceCopy = dataLeftCopy.Data as IDataSource;
            Assert.AreEqual(dataSource.Assembly, dataSourceCopy.Assembly, "unexpected assembly in condition1copy.dataleft.data");
            Assert.AreEqual(dataSource.Class, dataSourceCopy.Class, "unexpected class in condition1copy.dataleft.data");
            Assert.AreEqual(dataSource.Name.Identifier, dataSourceCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.dataleft.data");
            Assert.AreEqual(dataSource.Name.Value, dataSourceCopy.Name.Value, "unexpected name in condition1copy.dataleft.data");

            //condition1copy.dataleft.data.method 
            IDataMethod dataMethod = dataSource.Method as IDataMethod;
            IDataMethod dataMethodCopy = dataSourceCopy.Method as IDataMethod;
            Assert.AreEqual(dataMethod.Name.Identifier, dataMethodCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method");
            Assert.AreEqual(dataMethod.Name.Value, dataMethodCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method");
            Assert.AreEqual(dataMethod.Parameters.Count, dataMethodCopy.Parameters.Count, "unexpected number of parameters in condition1copy.dataleft.data.method");

            //condition1copy.dataleft.data.method.parameters[0]
            IParameter parameter = dataMethod.Parameters[0];
            IParameter parameterCopy = dataMethodCopy.Parameters[0];
            Assert.AreEqual(parameter.Name.Identifier, parameterCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[0]");
            Assert.AreEqual(parameter.Name.Value, parameterCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[0]");

            //condition1copy.dataleft.data.method.parameters[0].value
            IDataElement dataElement = dataMethod.Parameters[0].Value as IDataElement;
            IDataElement dataElementCopy = dataMethodCopy.Parameters[0].Value as IDataElement;
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condition1copy.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(dataElement.ReadOnly, dataElementCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[0].value");
            Assert.AreEqual(dataElement.Type, dataElementCopy.Type, "unexpected datatype in condition1copy.dataleft.data.method.parameters[0].value");

            //condition1copy.dataleft.data.method.parameters[0].value.data
            dataSource = dataElement.Data as IDataSource;
            dataSourceCopy = dataElementCopy.Data as IDataSource;
            Assert.AreEqual(dataSource.Assembly, dataSourceCopy.Assembly, "unexpected assembly in condition1copy.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual(dataSource.Class, dataSourceCopy.Class, "unexpected class in condition1copy.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual(dataSource.Name.Identifier, dataSourceCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[0].value.data");
            Assert.AreEqual(dataSource.Name.Value, dataSourceCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[0].value.data");

            //condition1copy.dataleft.data.method.parameters[0].value.data.method
            IDataMethod fileDataMethod = dataSource.Method as IDataMethod;
            IDataMethod fileDataMethodCopy = dataSourceCopy.Method as IDataMethod;
            Assert.AreEqual(fileDataMethod.Name.Identifier, fileDataMethodCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[0].value.method");
            Assert.AreEqual(fileDataMethod.Name.Value, fileDataMethodCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[0].value.data.method");
            Assert.AreEqual(fileDataMethod.Parameters.Count, fileDataMethodCopy.Parameters.Count, "unexpected number of parameters in condition1copy.dataleft.data.method.parameters[0].value.data.method");

            //condition1copy.dataleft.data.method.parameters[1]
            parameter = dataMethod.Parameters[1];
            parameterCopy = dataMethodCopy.Parameters[1];
            Assert.AreEqual(parameter.Name.Identifier, parameterCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[1]");
            Assert.AreEqual(parameter.Name.Value, parameterCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[1]");

            //condition1copy.dataleft.data.method.parameters[1].value
            dataElement = parameter.Value as IDataElement;
            dataElementCopy = parameterCopy.Value as IDataElement;
            Assert.IsNotNull(dataElementCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataElement.ReadOnly, dataElementCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(DataType.StringArray, dataElement.Type, "unexpected datatype in condition1copy.dataleft.data.method.parameters[1].value");

            //condition1copy.dataleft.data.method.parameters[1].value.data
            IPolicyObjectCollection<IDataItem> collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            IPolicyObjectCollection<IDataItem> collectionCopy = dataElementCopy.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collectionCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[1].value.data");
            Assert.AreEqual(collection.Count, collectionCopy.Count, "unexpected number of items in condition1copy.dataleft.data.method.parameters[1].value.data");

            //condition1copy.dataleft.data.method.parameters[1].value.data[0]
            IDataItem dataItem = collection[0] as IDataItem;
            IDataItem dataItemCopy = collectionCopy[0] as IDataItem;
            Assert.IsNotNull(dataItemCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(dataItem.Name.Identifier, dataItemCopy.Name.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[1].value");
            Assert.AreEqual(dataItem.Name.Value, dataItemCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(dataItem.ReadOnly, dataItemCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[1].value.data[0]");
            Assert.AreEqual(dataItem.Value, dataItemCopy.Value, "unexpected value in condition1copy.dataleft.data.method.parameters[1].value.data[0]");

            //condition1copy.dataleft.data.method.parameters[2]
            parameter = dataMethod.Parameters[2];
            parameterCopy = dataMethodCopy.Parameters[2];
            Assert.AreEqual(parameter.Name.Identifier, parameterCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[2]");
            Assert.AreEqual(parameter.Name.Value, parameterCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[2]");

            //condition1copy.dataleft.data.method.parameters[2].value
            dataElement = parameter.Value as IDataElement;
            dataElementCopy = parameter.Value as IDataElement;
            Assert.IsNotNull(dataElementCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.ReadOnly, dataElementCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[2].value");
            Assert.AreEqual(dataElement.Type, dataElementCopy.Type, "unexpected datatype in condition1copy.dataleft.data.method.parameters[2].value");

            //condition1copy.dataleft.data.method.parameters[2].value.data
            collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            collectionCopy = dataElementCopy.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collectionCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[2].value.data");
            Assert.AreEqual(collection.Count, collectionCopy.Count, "unexpected number of items in condition1copy.dataleft.data.method.parameters[2].value.data");

            //condition1copy.dataleft.data.method.parameters[3]
            parameter = dataMethod.Parameters[3];
            parameterCopy = dataMethodCopy.Parameters[3];
            Assert.AreEqual(parameter.Name.Identifier, parameterCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[3]");
            Assert.AreEqual(parameter.Name.Value, parameterCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[3]");

            //condition1copy.dataleft.data.method.parameters[3].value
            dataElement = parameter.Value as IDataElement;
            dataElementCopy = parameterCopy.Value as IDataElement;
            Assert.IsNotNull(dataElementCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.ReadOnly, dataElementCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[3].value");
            Assert.AreEqual(dataElement.Type, dataElementCopy.Type, "unexpected datatype in condition1copy.dataleft.data.method.parameters[3].value");

            //condition1copy.dataleft.data.method.parameters[3].value.data
            collection = dataElement.Data as IPolicyObjectCollection<IDataItem>;
            collectionCopy = dataElementCopy.Data as IPolicyObjectCollection<IDataItem>;
            Assert.IsNotNull(collectionCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[3].value.data");
            Assert.AreEqual(collection.Count, collectionCopy.Count, "unexpected number of items in condition1copy.dataleft.data.method.parameters[3].value.data");

            //condition1copy.dataleft.data.method.parameters[3].value.data[0]
            dataItem = collection[0] as IDataItem;
            dataItemCopy = collectionCopy[0] as IDataItem;
            Assert.IsNotNull(dataItemCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(dataItem.Name.Identifier, dataItemCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(dataItem.Name.Value, dataItemCopy.Name.Value, "unexpected name in condition1copy.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(dataItem.ReadOnly, dataItemCopy.ReadOnly, "unexpected readonly in condition1copy.dataleft.data.method.parameters[3].value.data[0]");
            Assert.AreEqual(dataItem.Value, dataItemCopy.Value, "unexpected value in conditiongroup.conditions[1].dataleft.data.method.parameters[3].value.data[0]");

            //condition1copy.dataright
            IDataElement dataRight = condition1.DataRight as IDataElement;
            IDataElement dataRightCopy = condition1Copy.DataRight as IDataElement;
            Assert.AreEqual(Guid.Empty, dataRightCopy.DisplayName.Identifier, "unexpected displayname identifier in condition1copy.dataright");
            Assert.AreEqual(dataRight.DisplayName.Value, dataRightCopy.DisplayName.Value, "unexpected display name in condition1copy.dataright");
            Assert.AreEqual(dataRight.Name.Identifier, dataRightCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataright");
            Assert.AreEqual(dataRight.Name.Value, dataRightCopy.Name.Value, "unexpected name in condition1copy.dataright");
            Assert.AreEqual(dataRight.ReadOnly, dataRightCopy.ReadOnly, "unexpected readonly in condition1copy.dataright");
            Assert.AreEqual(dataRight.Type, dataRightCopy.Type, "unexpected type in condition1copy.dataright");

            //condition1copy.dataright.data
            dataItem = dataRight.Data as IDataItem;
            dataItemCopy = dataRightCopy.Data as IDataItem;
            Assert.AreEqual(dataItem.Name.Identifier, dataItemCopy.Name.Identifier, "unexpected name identifier in condition1copy.dataright.data");
            Assert.AreEqual(dataItem.Name.Value, dataItemCopy.Name.Value, "unexpected name in condition1copy.dataright.data");
            Assert.AreEqual(dataItem.ReadOnly, dataItemCopy.ReadOnly, "unexpected readonly in condition1copy.dataright.data");
            Assert.AreEqual(dataItem.Value, dataItemCopy.Value, "unexpected value in condition1copy.dataright.data");                

            //condition2copy
            Assert.IsNotNull(condition2Copy, "unexpected object type in condition2copy");
            Assert.AreNotEqual(condition2.Identifier, condition2Copy.Identifier);
            Assert.AreEqual(condition2.Name.Value, condition2Copy.Name.Value);
            Assert.AreEqual(condition2.Class, condition2Copy.Class);
            Assert.AreEqual(condition2.Operator, condition2Copy.Operator);
            Assert.AreEqual(Guid.Empty, condition2Copy["preDefinedConditionType"].Identifier, "unexpected identifier on pre-defined condition type in conditiongroup");
            Assert.AreEqual(condition2["preDefinedConditionType"].Value, condition2Copy["preDefinedConditionType"].Value, "unexpected pre-defined condition type on condition2");
            Assert.AreEqual(Guid.Empty, condition2Copy["expressionEntity"].Identifier, "unexpected identifier on \"ExpressionEntity\" attribute in condition2");
            Assert.AreEqual(condition2["expressionEntity"].Value, condition2Copy["expressionEntity"].Value, "unexpected \"ExpressionEntity\" attribute in condition2");

            //condition2copy.dataleft
            dataElement = condition2.DataLeft as IDataElement;
            dataElementCopy = condition2Copy.DataLeft as IDataElement;
            Assert.AreNotEqual(dataElement.Identifier, dataElementCopy.Identifier, "unexpected identifier in condtion2copy.dataleft");
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condtion2copy.dataleft"); //non-translatable
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condtion2copy.dataleft");
            Assert.AreEqual(dataElement.Type, dataElementCopy.Type, "unexpected type in condtion2copy.dataleft");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condtion2copy.dataleft"); //nontranslateable
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condtion2copy.dataleft");

            //condition2copy.dataleft.data 
            dataSource = dataElement.Data as IDataSource;
            dataSourceCopy = dataElementCopy.Data as IDataSource;
            Assert.IsNotNull(dataSourceCopy, "unexpected object type in condition2copy.dataleft.data");
            Assert.AreNotEqual(dataSource.Identifier, dataSourceCopy.Identifier, "unexpected identifier in condtion2copy.dataleft.data");
            Assert.AreEqual(dataSource.Assembly, dataSourceCopy.Assembly, "unexpected assembly in condition2copy.dataleft.data");
            Assert.AreEqual(dataSource.Class, dataSourceCopy.Class, "unexpected class in condition2copy.dataleft.data");
            Assert.AreEqual(dataSource.Name.Identifier, dataSourceCopy.Name.Identifier, "unexpected name identifier in condition2copy.dataleft.data"); //nontranslateable
            Assert.AreEqual(dataSource.Name.Value, dataSourceCopy.Name.Value, "unexpected name in condition2copy.dataleft.data");

            //assume that lower level copying is working, as we have already tested in condition 1 and it is covered in the 
            //object model tests

            //condition3Copy
            Assert.AreNotEqual(condition3.Identifier, condition3Copy.Identifier);
            Assert.AreEqual(condition3.Name.Value, condition3Copy.Name.Value);
            Assert.AreEqual(condition3.Class, condition3Copy.Class);
            Assert.AreEqual(condition3.Operator, condition3Copy.Operator);
            Assert.AreEqual(Guid.Empty, condition3Copy["preDefinedConditionType"].Identifier, "unexpected identifier on pre-defined condition type in condition3");
            Assert.AreEqual(condition3["preDefinedConditionType"].Value, condition3Copy["preDefinedConditionType"].Value, "unexpected pre-defined condition type on condition3");
            Assert.AreEqual(Guid.Empty, condition3Copy["expressionEntity"].Identifier, "unexpected identifier on \"ExpressionEntity\" attribute in condition3");
            Assert.AreEqual(condition3["expressionEntity"].Value, condition3Copy["expressionEntity"].Value, "unexpected \"ExpressionEntity\" attribute in condition3");

            //condition3copy.dataleft
            dataElement = condition3.DataLeft as IDataElement;
            dataElementCopy = condition3Copy.DataLeft as IDataElement;
            Assert.AreNotEqual(dataElement.Identifier, dataElementCopy.Identifier, "unexpected identifier in condtion3copy.dataleft");
            Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier, "unexpected name identifier in condtion3copy.dataleft"); //non-translatable
            Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value, "unexpected name in condtion3copy.dataleft");
            Assert.AreEqual(dataElement.Type, dataElementCopy.Type, "unexpected type in condtion3copy.dataleft");
            Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier, "unexpected displayname identifier in condtion3copy.dataleft"); //nontranslateable
            Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value, "unexpected displayname in condtion3copy.dataleft");

            //condition3copy.dataleft.data 
            dataSource = dataElement.Data as IDataSource;
            dataSourceCopy = dataElementCopy.Data as IDataSource;
            Assert.IsNotNull(dataSource, "unexpected object type in condition3copy.dataleft.data");
            Assert.AreNotEqual(dataSource.Identifier, dataSourceCopy.Identifier, "unexpected identifier in condtion3copy.dataleft.data");
            Assert.AreEqual(dataSource.Assembly, dataSourceCopy.Assembly, "unexpected assembly in condition3copy.dataleft.data");
            Assert.AreEqual(dataSource.Class, dataSourceCopy.Class, "unexpected class in condition3copy.dataleft.data");
            Assert.AreEqual(dataSource.Name.Identifier, dataSourceCopy.Name.Identifier, "unexpected name identifier in condition3copy.dataleft.data"); //nontranslateable
            Assert.AreEqual(dataSource.Name.Value, dataSourceCopy.Name.Value, "unexpected name in condition3copy.dataleft.data");

            //assume that lower level copying is working, as we have already tested in condition 1 and it is covered in the 
            //object model tests

            //test state machine state
            m_stateMachine.Verify();

        }