示例#1
0
        public void TestOrdering()
        {
            Lifetime.Using(lifetime =>
            {
                SynchronousScheduler.Instance.SetActive(lifetime);
                var serverProtocol = Server(lifetime);
                var clientProtocol = Client(lifetime, serverProtocol);

                var sp = new RdProperty <int>().Static(1);
                sp.Bind(lifetime, serverProtocol, Top);
                var cp = new RdProperty <int>().Static(1);
                cp.Bind(lifetime, clientProtocol, Top);

                var log = new List <int>();
                sp.Advise(lifetime, it => log.Add(it));
                sp.SetValue(1);
                sp.SetValue(2);
                sp.SetValue(3);
                sp.SetValue(4);
                sp.SetValue(5);

                while (log.Count < 5)
                {
                    Thread.Sleep(10);
                }
                CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5 }, log);
            });
        }