Ooui-tws-port/Tests/NodeTests.cs

66 lines
1.8 KiB
C#
Raw Normal View History

2017-06-18 06:21:49 +00:00
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ooui;
namespace Tests
{
[TestClass]
public class NodeTests
{
[TestMethod]
public void TextState ()
{
var b = new Button ();
Assert.AreEqual (1, b.StateMessages.Count);
b.Text = "Hello";
Assert.AreEqual (2, b.StateMessages.Count);
b.Text = "Bye";
Assert.AreEqual (2, b.StateMessages.Count);
}
[TestMethod]
public void InsertBeforeOfRemovedNodeStillWorks ()
{
var p = new Div ();
var c0 = new Span ();
var c1 = new Span ();
var c2 = new Span ();
p.InsertBefore (c2, null);
p.InsertBefore (c1, c2);
p.InsertBefore (c0, c1);
p.RemoveChild (c1);
var ms = p.StateMessages;
Assert.AreEqual (3, ms.Count);
var c0s = (Array)ms[2].Value;
Assert.AreEqual (2, c0s.Length);
Assert.AreEqual (c0, c0s.GetValue (0));
Assert.AreEqual (c2, c0s.GetValue (1));
}
2017-06-24 19:58:14 +00:00
[TestMethod]
public void EventReceptionBubblesDown ()
{
var p = new Div ();
var b = new Button ();
p.AppendChild (b);
var clicked = false;
b.Clicked += (s, e) => {
clicked = true;
};
p.Receive (Message.Event (b.Id, "click"));
Assert.IsTrue (clicked);
}
2017-06-24 20:34:47 +00:00
[TestMethod]
public void ValueBubblesDown ()
{
var p = new Div ();
var b = new Input ();
p.AppendChild (b);
p.Receive (Message.Event (b.Id, "change", "please work"));
Assert.AreEqual ("please work", b.Value);
}
2017-06-18 06:21:49 +00:00
}
}