public void Cloning()
        {
            try {
                LayoutElement[] layoutElement = new LayoutElement[8];

                layoutElement[0] = new LayoutElement();
                layoutElement[0].Data = new DataElement(EntryDataType.Notes);
                layoutElement[0].Title = "Notes for me";
                layoutElement[0].Width = 123;
                layoutElement[0].Filter = new Filter();

                Assert.Equals(layoutElement[0], layoutElement[0].Clone(), "Clone()");

                layoutElement[1] = layoutElement[0].Clone();
                layoutElement[1].Data = new DataElement(EntryDataType.Notes);
                Assert.Equals(layoutElement[0], layoutElement[1], "Data same meaning, different object.");

                layoutElement[1].Data = new DataElement(EntryDataType.Empty);
                Assert.NotEquals(layoutElement[0], layoutElement[1], "Different Data");

                layoutElement[1] = layoutElement[0].Clone();
                layoutElement[1].Title = "Different title";
                Assert.NotEquals(layoutElement[0], layoutElement[1], "Different Title");

                layoutElement[1] = layoutElement[0].Clone();
                layoutElement[1].Width = 999;
                Assert.NotEquals(layoutElement[0], layoutElement[1], "Different Width");

                Filter filter;

                layoutElement[1] = layoutElement[0].Clone();
                filter = new Filter();
                filter.Comparator = "<=";
                layoutElement[1].Filter = filter;
                Assert.NotEquals(layoutElement[0], layoutElement[1], "Different Filter");

                layoutElement[1] = layoutElement[0].Clone();
                filter = new Filter();
                layoutElement[1].Filter = filter;
                Assert.Equals(layoutElement[0], layoutElement[1], "Same Filter");

            } catch (Exception e) {
                Assert.Fail("Exception: " + e.GetType().Name + "\n" + e.Message + "\n" + e.StackTrace);
            }
        }
Beispiel #2
0
 public Filter Clone()
 {
     Filter item = new Filter();
     item.Comparator = this.Comparator;
     item.CompareWith = this.CompareWith;
     item.Enabled = this.Enabled;
     return item;
 }