Esempio n. 1
0
        [Test] public void isCloneable()
        {
            double       xFactor      = 2.3;
            double       yFactor      = 3.4;
            Point        origLocation = new Point(30, 30);
            const string val          = "theValue";

            GuiProperty <string> original = new GuiProperty <string>(val, xFactor, yFactor);

            original.Location = origLocation;

            GuiProperty <string> clone = (GuiProperty <string>)original.Clone();

            original.Content = "newContents";
            original.Location.Offset(10, 10);
            original.LocationRelative.XFactor += 0.1;
            original.LocationRelative.YFactor += 0.1;

            // Use constant or hardcoded values in Assertions to avoid incorrect testing
            // due to the fact, that the references of the 'check' values just point
            // to the value being checked

            Assert.That(clone.LocationRelative.XFactor, Is.EqualTo(xFactor));
            Assert.That(clone.LocationRelative.YFactor, Is.EqualTo(yFactor));
            Assert.That(clone.Location, Is.EqualTo(new Point(30, 30)));
            Assert.That(clone.Content, Is.EqualTo(val));
        }
Esempio n. 2
0
        [Test] public void Clone_clonesContentsIfItImplementsICloneable()
        {
            const string origString = "original";
            var          reference  = new CloneableClass(origString);
            var          original   = new GuiProperty <CloneableClass>(reference);

            var clone = (GuiProperty <CloneableClass>)original.Clone();

            clone.Content.check = "clone";

            Assert.That(original.Content.check, Is.EqualTo(origString));
        }