public void TestWoopsaClientSubscriptionChannel()
        {
            bool             isValueChanged = false;
            TestObjectServer objectServer   = new TestObjectServer();

            using (WoopsaServer server = new WoopsaServer(objectServer, TestingPort))
            {
                using (WoopsaClient client = new WoopsaClient(TestingUrl))
                {
                    WoopsaBoundClientObject  root         = client.CreateBoundRoot();
                    WoopsaClientSubscription subscription = root.Subscribe(nameof(TestObjectServer.Votes),
                                                                           (sender, e) => { isValueChanged = true; },
                                                                           TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20));
                    Stopwatch watch = new Stopwatch();
                    watch.Start();
                    while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(20)))
                    {
                        Thread.Sleep(10);
                    }
                    if (isValueChanged)
                    {
                        Console.WriteLine("Notification after {0} ms", watch.Elapsed.TotalMilliseconds);
                    }
                    else
                    {
                        Console.WriteLine("No notification received");
                    }
                    subscription.Unsubscribe();
                    Assert.AreEqual(true, isValueChanged);
                }
            }
        }
        public void TestWoopsaClientSubscriptionChannel5000SubscriptionsObservableCollection()
        {
            const int objectsCount       = 5000;
            int       totalNotifications = 0;
            ObservableCollection <ManySubscriptionTestObject> list =
                new ObservableCollection <ManySubscriptionTestObject>();

            for (int i = 0; i < objectsCount; i++)
            {
                list.Add(new ManySubscriptionTestObject()
                {
                    Trigger = i
                });
            }
            using (WoopsaServer server = new WoopsaServer(new WoopsaObjectAdapter(null, "list", list, null, null,
                                                                                  WoopsaObjectAdapterOptions.None, WoopsaVisibility.DefaultIsVisible | WoopsaVisibility.IEnumerableObject), TestingPort))
            {
                using (WoopsaClient client = new WoopsaClient(TestingUrl, null, objectsCount))
                {
                    WoopsaBoundClientObject root = client.CreateBoundRoot();
                    for (int i = 0; i < list.Count; i++)
                    {
                        int index = i;
                        WoopsaClientSubscription subscription = root.Subscribe(
                            WoopsaUtils.CombinePath(
                                WoopsaObjectAdapter.EnumerableItemDefaultName(i),
                                nameof(ManySubscriptionTestObject.Trigger)),
                            (sender, e) =>
                        {
                            list[index].HasNotified = true;
                            totalNotifications++;
                        },
                            TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(200));
                    }
                    Stopwatch watch = new Stopwatch();
                    watch.Start();
                    while ((totalNotifications < objectsCount) && (watch.Elapsed < TimeSpan.FromSeconds(500)))
                    {
                        Thread.Sleep(10);
                    }
                    if (totalNotifications == objectsCount)
                    {
                        Console.WriteLine("All notification after {0} ms", watch.Elapsed.TotalMilliseconds);
                    }
                    else
                    {
                        Console.WriteLine("{0} notification received, {1} expected", totalNotifications, objectsCount);
                    }
                    Assert.AreEqual(objectsCount, totalNotifications);
                }
            }
        }
        public void TestWoopsaClientSubscriptionChannelUnexistingItem()
        {
            TestObjectServer objectServer = new TestObjectServer();

            using (WoopsaServer server = new WoopsaServer(objectServer, TestingPort))
            {
                using (WoopsaClient client = new WoopsaClient(TestingUrl))
                {
                    WoopsaBoundClientObject root = client.CreateBoundRoot();
                    try
                    {
                        WoopsaClientSubscription sub = root.Subscribe("ThisDoesNotExistInTheServer",
                                                                      (sender, e) => { },
                                                                      TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20));
                        Assert.Fail();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        public void TestWoopsaClientSubscriptionChannelNoRemoteSubscriptionService()
        {
            bool           isValueChanged = false;
            WoopsaObject   objectServer   = new WoopsaObject(null, "");
            int            votes          = 0;
            WoopsaProperty propertyVotes  = new WoopsaProperty(objectServer, "Votes", WoopsaValueType.Integer, (p) => votes,
                                                               (p, value) => { votes = value.ToInt32(); });

            using (WoopsaServer server = new WoopsaServer((IWoopsaContainer)objectServer, TestingPort))
            {
                using (WoopsaClient client = new WoopsaClient(TestingUrl))
                {
                    WoopsaBoundClientObject  root         = client.CreateBoundRoot();
                    WoopsaClientSubscription subscription = root.Subscribe(nameof(TestObjectServer.Votes),
                                                                           (sender, e) => { isValueChanged = true; },
                                                                           TimeSpan.FromMilliseconds(10), TimeSpan.FromMilliseconds(20));
                    votes = 2;
                    Stopwatch watch = new Stopwatch();
                    watch.Start();
                    while ((!isValueChanged) && (watch.Elapsed < TimeSpan.FromSeconds(2000)))
                    {
                        Thread.Sleep(10);
                    }
                    if (isValueChanged)
                    {
                        Console.WriteLine("Notification after {0} ms", watch.Elapsed.TotalMilliseconds);
                    }
                    else
                    {
                        Console.WriteLine("No notification received");
                    }
                    subscription.Unsubscribe();
                    Assert.AreEqual(true, isValueChanged);
                }
            }
        }