public static void Main() { EventTestClass etc = new EventTestClass(3); etc.SetValue(5); etc.SetValue(5); etc.SetValue(3); }
public void EventTest() { var service = new EventTestClass(); var root = new Root( new DeviceType("schemas-upnp-org", "mono-upnp-test-device", new Version(1, 0)), "uuid:d1", "Mono.Upnp.Tests Device", "Mono Project", "Device", new DeviceOptions { Services = new[] { new Service <EventTestClass> ( new ServiceType("schemas-upnp-org", "mono-upnp-test-service", new Version(1, 0)), "urn:upnp-org:serviceId:testService1", service ) } } ); var helper = new EventTestHelperClass(service, mutex); using (var server = new Server(root)) { using (var client = new Client()) { client.ServiceAdded += (sender, args) => { try { var controller = args.Service.GetService().GetController(); controller.StateVariables["FooChanged"].ValueChanged += helper.FirstEventHandler; } catch (Exception e) { helper.Exception = e; lock (mutex) { Monitor.Pulse(mutex); } } }; client.Browse(new ServiceType("schemas-upnp-org", "mono-upnp-test-service", new Version(1, 0))); lock (mutex) { server.Start(); service.Foo = "Hello World!"; if (!Monitor.Wait(mutex, TimeSpan.FromSeconds(30))) { Assert.Fail("The event timed out."); } } } } if (helper.Exception != null) { throw helper.Exception; } }
public void EventTest () { var service = new EventTestClass (); var root = new Root ( new DeviceType ("schemas-upnp-org", "mono-upnp-test-device", new Version (1, 0)), "uuid:d1", "Mono.Upnp.Tests Device", "Mono Project", "Device", new RootDeviceOptions { Services = new[] { new Service<EventTestClass> ( new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)), "urn:upnp-org:serviceId:testService1", service ) } } ); var helper = new EventTestHelperClass (service, mutex); using (var server = new Server (root)) { using (var client = new Client ()) { client.ServiceAdded += (sender, args) => { try { var controller = args.Service.GetService ().GetController (); controller.StateVariables["FooChanged"].ValueChanged += helper.FirstEventHandler; } catch (Exception e) { helper.Exception = e; lock (mutex) { Monitor.Pulse (mutex); } } }; client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0))); lock (mutex) { server.Start (); service.Foo = "Hello World!"; if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) { Assert.Fail ("The event timed out."); } } } } if (helper.Exception != null) { throw helper.Exception; } }
public EventTestHelperClass (EventTestClass service, object mutex) { this.service = service; this.mutex = mutex; }
public EventTestHelperClass(EventTestClass service, object mutex) { this.service = service; this.mutex = mutex; }