2017-06-18 19:52:51 +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-18 19:52:51 +00:00
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2017-07-07 18:47:59 +00:00
|
|
|
#endif
|
2017-06-18 19:52:51 +00:00
|
|
|
|
|
|
|
using Ooui;
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
{
|
|
|
|
[TestClass]
|
|
|
|
public class StyleTests
|
|
|
|
{
|
2017-06-18 20:00:07 +00:00
|
|
|
[TestMethod]
|
|
|
|
public void DefaultIsInherit ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
Assert.AreEqual ("inherit", s.BackgroundColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void NullMakesInherit ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
s.BackgroundColor = "red";
|
|
|
|
Assert.AreEqual ("red", s.BackgroundColor);
|
|
|
|
s.BackgroundColor = null;
|
|
|
|
Assert.AreEqual ("inherit", s.BackgroundColor);
|
|
|
|
}
|
|
|
|
|
2017-06-18 19:52:51 +00:00
|
|
|
[TestMethod]
|
|
|
|
public void ChangedWhen ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
var changeCount = 0;
|
|
|
|
s.PropertyChanged += (_, e) => changeCount++;
|
|
|
|
s.BackgroundColor = "red";
|
|
|
|
Assert.AreEqual (1, changeCount);
|
|
|
|
s.BackgroundColor = "blue";
|
|
|
|
Assert.AreEqual (2, changeCount);
|
|
|
|
s.BackgroundColor = "blue";
|
|
|
|
Assert.AreEqual (2, changeCount);
|
|
|
|
}
|
2017-06-18 21:26:32 +00:00
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void EmptyString ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
Assert.AreEqual ("", s.ToString ());
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void SingleString ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
s.BackgroundColor = "red";
|
|
|
|
Assert.AreEqual ("background-color:red", s.ToString ());
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void NullString ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
s.BackgroundColor = "red";
|
|
|
|
s.BackgroundColor = null;
|
|
|
|
Assert.AreEqual ("", s.ToString ());
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void FloatString ()
|
|
|
|
{
|
|
|
|
var s = new Style ();
|
|
|
|
s.BorderLeftWidth = 3.142;
|
2017-12-10 22:26:59 +00:00
|
|
|
Assert.AreEqual ("border-left-width:3.142px", s.ToString ());
|
2017-06-18 21:26:32 +00:00
|
|
|
}
|
2017-06-18 23:50:22 +00:00
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void JsName ()
|
|
|
|
{
|
|
|
|
Assert.AreEqual ("borderLeftWidth", Style.GetJsName ("border-left-width"));
|
|
|
|
}
|
2017-06-18 19:52:51 +00:00
|
|
|
}
|
|
|
|
}
|