2017-06-18 19:52:51 +00:00
|
|
|
using System;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
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;
|
|
|
|
Assert.AreEqual ("border-left-width:3.142", s.ToString ());
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|