コード例 #1
0
ファイル: TestProxy.cs プロジェクト: daviddw/oss-public
        public Runner()
        {
            iDeviceList = new List <CpDevice>();
            CpDeviceList.ChangeHandler  added   = new CpDeviceList.ChangeHandler(DeviceAdded);
            CpDeviceList.ChangeHandler  removed = new CpDeviceList.ChangeHandler(DeviceRemoved);
            CpDeviceListUpnpServiceType list    = new CpDeviceListUpnpServiceType("upnp.org", "ConnectionManager", 1, added, removed);
            //CpDeviceListUpnpUuid list = new CpDeviceListUpnpUuid("896659847466-a4badbeaacbc-737837", added, removed);
            Semaphore sem = new Semaphore(0, 1);

            sem.WaitOne(6000);

            InvokeSync();
            // Note that following tests handle the device list changing (i.e. devices being switched on/off) badly

            Console.Write("\n\n");
            int      count     = iDeviceList.Count;
            DateTime startTime = DateTime.Now;

            PollInvoke();
            DateTime endTime    = DateTime.Now;
            uint     avgActions = 0;

            if (count > 0)
            {
                avgActions = (uint)(iActionCount / count);
            }
            double secs = endTime.Subtract(startTime).TotalSeconds;

            Console.Write("\n" + iActionCount + " actions invoked on " + count + " devices (avg " + avgActions + ") in " + secs + " seconds\n\n");

            Console.Write("\n\n");
            startTime = DateTime.Now;
            PollSubscribe();
            endTime = DateTime.Now;
            uint avgSubscriptions = 0;

            if (count > 0)
            {
                avgSubscriptions = (uint)(iSubscriptionCount / count);
            }
            secs = endTime.Subtract(startTime).TotalSeconds;
            Console.Write("\n" + iSubscriptionCount + " subscriptions on " + count + " devices (avg " + avgSubscriptions + ") in " + secs + " seconds\n\n");

            list.Dispose();
            Console.Write("Tests completed\n");
        }
コード例 #2
0
        public Runner()
        {
            Console.Write("TestDvDeviceCpp - starting\n");

            iUpdatesComplete = new Semaphore(0, Int32.MaxValue);
            iSingleChanged   = new Semaphore(0, Int32.MaxValue);
            DeviceBasic device = new DeviceBasic();

            iDeviceList = new List <CpDevice>();
            CpDeviceList.ChangeHandler  added   = new CpDeviceList.ChangeHandler(DeviceAdded);
            CpDeviceList.ChangeHandler  removed = new CpDeviceList.ChangeHandler(DeviceRemoved);
            CpDeviceListUpnpServiceType list    = new CpDeviceListUpnpServiceType("zapp.org", "TestBasic", 1, added, removed);
            Semaphore sem = new Semaphore(0, 1);

            sem.WaitOne(1000);
            TestActions();
            TestSubscriptions();
            list.Dispose();
            device.Dispose();

            Console.Write("TestDvDeviceCpp - completed\n");
        }