2017-06-19 07:08:33 +00:00
|
|
|
using System;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
using Ooui;
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
{
|
|
|
|
[TestClass]
|
|
|
|
public class CanvasTests
|
|
|
|
{
|
|
|
|
[TestMethod]
|
2017-06-20 04:55:20 +00:00
|
|
|
public void Context2DState ()
|
2017-06-19 07:08:33 +00:00
|
|
|
{
|
|
|
|
var c = new Canvas ();
|
|
|
|
Assert.AreEqual (1, c.StateMessages.Count);
|
2017-06-20 04:55:20 +00:00
|
|
|
var c2d = c.GetContext2D ();
|
2017-06-19 07:08:33 +00:00
|
|
|
Assert.AreEqual (2, c.StateMessages.Count);
|
2017-06-20 04:55:20 +00:00
|
|
|
var c2d2 = c.GetContext2D ();
|
2017-06-19 07:08:33 +00:00
|
|
|
Assert.AreEqual (2, c.StateMessages.Count);
|
|
|
|
Assert.AreEqual (c2d, c2d2);
|
2017-06-20 04:58:06 +00:00
|
|
|
Assert.AreEqual (0, c2d.StateMessages.Count);
|
2017-06-19 07:08:33 +00:00
|
|
|
}
|
2017-06-19 07:18:25 +00:00
|
|
|
|
|
|
|
[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;
|
2017-06-19 07:19:35 +00:00
|
|
|
c.Height = -100;
|
2017-06-19 07:18:25 +00:00
|
|
|
Assert.AreEqual (150, c.Width);
|
|
|
|
Assert.AreEqual (150, c.Height);
|
|
|
|
}
|
2017-06-19 07:08:33 +00:00
|
|
|
}
|
|
|
|
}
|