Пример #1
0
        public void TestAddLocalDevice()
        {
            Console.WriteLine("Test to add a local upnp device.");
            UPnP u = new UPnP();
            u.SetupSockets();
            MediaBrowser mb = new MediaBrowser();
            bool wait = true;
            //     wait = false;
            mb.RootDevice.FriendlyName = "vpMediaTestserver";
            mb.BrowseRequestReceived += delegate(MediaBrowser media_browser,string object_id,string browse_flag,int starting_index,int requested_count,string sort_criteria)
            {
                Console.WriteLine("Browse request received: \nobject_id: "+object_id+"\nbrowse_flag: "+browse_flag+"\nstarting_index: "+starting_index+"\nrequested_count: "+requested_count+"\nsort_criteria: "+sort_criteria+"\n");
                MediaBrowser.BrowseResult result = new MediaBrowser.BrowseResult();
                if (object_id == "0")
                {
                    result.TotalMatches = 3;
                    result.AddFolder("Queue", "queue", "0", true, false, 3, "UNKNOWN", -1);
                    result.AddItem("test item", "pez2001", "http://www.voyagerproject.de/stuff/phat_sweet_drill_mix.wav.mp3", "audio/mpeg", "test", "0", false, -1, "UNKNOWN");
                    result.AddItem("test item 2", "pez2001", "http://www.voyagerproject.org/wp-content/uploads/2006/05/treiwund%20+%20graf%20contra2.mp3", "audio/mpeg", "test", "0", false, -1, "UNKNOWN");
                }
                else if (object_id == "queue")
                {
                    result.TotalMatches = 3;
                    result.AddFolder("Root", "0", "0", true, false, 3, "UNKNOWN", -1);
                    result.AddItem("test item b", "pez2001", "http://www.voyagerproject.de/stuff/phat_sweet_drill_mix.wav.mp3", "audio/mpeg", "test", "0", false, -1, "UNKNOWN");
                    result.AddItem("test item b 2", "pez2001", "http://www.voyagerproject.org/wp-content/uploads/2006/05/treiwund%20+%20graf%20contra2.mp3", "audio/mpeg", "test", "0", false, -1, "UNKNOWN");
                }
                return (result);
            };
            u.AddLocalDevice(mb);
            Console.WriteLine("Waiting for data");
            DateTime start = DateTime.Now;
            while (wait)
            {
                if (DateTime.Now - start > new TimeSpan(0, 0, 60))
                {
                    Console.WriteLine("");
                    Console.WriteLine("Operation took too long");
                    wait = false;
                    Assert.Fail("Operation took too long");
                }
                Console.Write(".");
                Thread.Sleep(250);
            }
            Console.WriteLine("UPnP Local Device Add Test successful.");

            u.CloseSockets();
        }