Add Width and Height to Canvas

This commit is contained in:
Frank A. Krueger 2017-06-19 00:18:25 -07:00
parent ebe427ff0f
commit 04092e9e9f
2 changed files with 46 additions and 0 deletions

View File

@ -7,6 +7,18 @@ namespace Ooui
Context2d context2d = new Context2d ();
int gotContext2d = 0;
int width = 150;
public int Width {
get => width;
set => SetProperty (ref width, value <= 0 ? 150 : value, "width");
}
int height = 150;
public int Height {
get => height;
set => SetProperty (ref height, value <= 0 ? 150 : value, "height");
}
public Canvas ()
: base ("canvas")
{

View File

@ -19,5 +19,39 @@ namespace Tests
Assert.AreEqual (2, c.StateMessages.Count);
Assert.AreEqual (c2d, c2d2);
}
[TestMethod]
public void DefaultWidthAndHeight ()
{
var c = new Canvas ();
Assert.AreEqual (150, c.Width);
Assert.AreEqual (150, c.Height);
}
[TestMethod]
public void WidthAndHeight ()
{
var c = new Canvas {
Width = 640,
Height = 480,
};
Assert.AreEqual (640, c.Width);
Assert.AreEqual (480, c.Height);
}
[TestMethod]
public void CantBeNegativeOrZero ()
{
var c = new Canvas {
Width = 640,
Height = 480,
};
Assert.AreEqual (640, c.Width);
Assert.AreEqual (480, c.Height);
c.Width = 0;
c.Height = 0;
Assert.AreEqual (150, c.Width);
Assert.AreEqual (150, c.Height);
}
}
}