Ooui-tws-port/Tests/CanvasTests.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2017-06-19 07:08:33 +00:00
using System;
2017-07-07 18:47:59 +00:00
#if NUNIT
using NUnit.Framework;
using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
using TestMethodAttribute = NUnit.Framework.TestCaseAttribute;
#else
2017-06-19 07:08:33 +00:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
2017-07-07 18:47:59 +00:00
#endif
2017-06-19 07:08:33 +00:00
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 ();
2017-07-08 05:53:32 +00:00
Assert.AreEqual (300, c.Width);
2017-06-19 07:18:25 +00:00
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;
2018-02-02 02:51:00 +00:00
Assert.AreEqual (0, c.Width);
Assert.AreEqual (0, c.Height);
2017-06-19 07:18:25 +00:00
}
2017-06-19 07:08:33 +00:00
}
}