예제 #1
0
        public void TestClone()
        {
            Condition condition = new Condition(Guid.NewGuid(), "className", new TranslateableLanguageItem(Guid.NewGuid()), OperatorType.Equals, false);

            condition.DataLeft = new DataElement(Guid.NewGuid(), new TranslateableLanguageItem(), new TranslateableLanguageItem("DataLeft"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem(Guid.NewGuid()), DataType.String, "data"), false);
            condition.DataRight = new DataElement(Guid.NewGuid(), new TranslateableLanguageItem(), new TranslateableLanguageItem("DataRight"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem(Guid.NewGuid()), DataType.String, "data"), false);

            Condition copy = condition.Clone() as Condition;

            Assert.IsNotNull(copy);
            Assert.AreNotEqual(condition.Identifier, copy.Identifier);
            Assert.AreEqual(condition.Class, copy.Class);
            Assert.AreNotEqual(condition.Name.Identifier, copy.Name.Identifier);
            Assert.AreEqual(condition.Name.Value, copy.Name.Value);
            Assert.AreEqual(condition.Operator, copy.Operator);
            Assert.AreEqual(condition.Parent, copy.Parent);
            Assert.AreEqual(condition.ReadOnly, copy.ReadOnly);

            Assert.IsNotNull(copy.DataLeft);
            Assert.AreEqual(condition.DataLeft.DisplayName.Value, copy.DataLeft.DisplayName.Value);
            Assert.AreNotEqual(condition.DataLeft.Identifier, copy.DataLeft.Identifier);
            Assert.AreNotEqual(condition.DataLeft.Name.Identifier, copy.DataLeft.Name.Identifier);
            Assert.AreEqual(condition.DataLeft.Name.Value, copy.DataLeft.Name.Value);
            Assert.AreEqual(condition.DataLeft.ReadOnly, copy.DataLeft.ReadOnly);
            Assert.AreEqual(condition.DataLeft.Type, copy.DataLeft.Type);

            DataItem conditionItem = condition.DataLeft.Data as DataItem;
            DataItem copyItem = copy.DataLeft.Data as DataItem;

            Assert.AreEqual(conditionItem.Name.Value, copyItem.Name.Value);
            Assert.AreEqual(conditionItem.ReadOnly, copyItem.ReadOnly);
            Assert.AreEqual(conditionItem.Value, copyItem.Value);

            Assert.IsNotNull(copy.DataRight);
            Assert.AreEqual(condition.DataRight.DisplayName.Value, copy.DataRight.DisplayName.Value);
            Assert.AreNotEqual(condition.DataRight.Identifier, copy.DataRight.Identifier);
            Assert.AreEqual(condition.DataRight.Name.Value, copy.DataRight.Name.Value);
            Assert.AreEqual(condition.DataRight.ReadOnly, copy.DataRight.ReadOnly);
            Assert.AreEqual(condition.DataRight.Type, copy.DataRight.Type);

            conditionItem = condition.DataRight.Data as DataItem;
            copyItem = copy.DataRight.Data as DataItem;

            Assert.AreEqual(conditionItem.Name.Value, copyItem.Name.Value);
            Assert.AreEqual(conditionItem.ReadOnly, copyItem.ReadOnly);
            Assert.AreEqual(conditionItem.Value, copyItem.Value);
        }
예제 #2
0
        public void TestClone_DataLeft_DataSource()
        {
            Condition condition = new Condition(Guid.NewGuid(), "className", new TranslateableLanguageItem(Guid.NewGuid()), OperatorType.Equals, false);

            DataMethod method = new DataMethod("dataMethod");
            DataSource source = new DataSource("source.assembly", "source.class", method);

            DataElement item = new DataElement(
                Guid.NewGuid(),
                new TranslateableLanguageItem(),
                new TranslateableLanguageItem("DataLeft"),
                DataType.Object,
                source
                );

            condition.DataLeft = item;

            Condition copyCondition = condition.Clone() as Condition;
            Assert.IsNotNull(copyCondition);
            Assert.IsNotNull(copyCondition.DataLeft);
            Assert.IsNotNull(item.Data as DataSource);
        }