When I run the following tests (In NUnit):
The second test fails... it says that the propertyRect.Re ctangle.X is still 0.
Any ideas why this behavior might be? I am stumped at this point.
Obviously I can get around it by offsetting the Rectangle before assigning it, I am just trying to figure out why I am seeing this behavior.
Thanks,
Matt
Code:
[Test]
public void ShouldOffsetRectangle() {
RectangleF standAloneRect = new RectangleF(0, 0, 10, 10);
standAloneRect.Offset(1, 1);
Assert.AreEqual(1, standAloneRect.X, "standAlone failed");
}
[Test]
public void ShouldOffsetRectangleAsProperty() {
TestRect propertyRect = new TestRect();
propertyRect.Rectangle = new RectangleF(0, 0, 10, 10);
propertyRect.Rectangle.Offset(1, 1);
Assert.AreEqual(1, propertyRect.Rectangle.X, "propertyRect failed");
}
private class TestRect {
public RectangleF Rectangle { get; set; }
}
Any ideas why this behavior might be? I am stumped at this point.
Obviously I can get around it by offsetting the Rectangle before assigning it, I am just trying to figure out why I am seeing this behavior.
Thanks,
Matt