Exemple #1
0
        public void SetWithPriorityTest()
        {
            using (var app = AppFactory.Empty())
            {
                ManualResetEvent called = new ManualResetEvent(false);

                var root = app.Child("/");

                // now update the priorites
                root.Child("aaa").SetWithPriority("{ name: 'aaa'}", 3);
                root.Child("bbb").SetWithPriority("{ name: 'bbb'}", 2);
                root.Child("ccc").SetWithPriority("{ name: 'ccc'}", 1);

                root.OrderByPriority().Once("value", (snap, child, context) =>
                {
                    var children = snap.Children.ToArray();
                    Assert.AreEqual("ccc", children[0].Key);
                    Assert.AreEqual(1, float.Parse(children[0].GetPriority().Value));
                    Assert.AreEqual("bbb", children[1].Key);
                    Assert.AreEqual(2, float.Parse(children[1].GetPriority().Value));
                    Assert.AreEqual("aaa", children[2].Key);
                    Assert.AreEqual(3, float.Parse(children[2].GetPriority().Value));
                    called.Set();
                });

                Assert.IsTrue(called.WaitOne(TimeSpan.FromSeconds(5)), "callback was never fired");
            }
        }
Exemple #2
0
 public void TestInit()
 {
     _app = AppFactory.Empty();
 }