コード例 #1
0
        public void ScpdTest()
        {
            var controller = CreateServiceController();
            var root       = new DummyRoot(
                new DeviceType("schemas-upnp-org", "mono-upnp-tests-device", new Version(1, 0)),
                "uuid:d1",
                "Mono.Upnp.Tests Device",
                "Mono Project",
                "Device",
                new DeviceOptions {
                Services = new[] {
                    new Service(
                        new ServiceType("uschemas-upnp-org", "mono-upnp-test-service", new Version(1, 0)),
                        "urn:upnp-org:serviceId:testService1",
                        controller
                        )
                }
            }
                );

            using (var server = new Server(root)) {
                server.Start();
                var request = WebRequest.Create(new Uri(root.UrlBase, "/service/0/scpd/"));
                using (var response = (HttpWebResponse)request.GetResponse()) {
                    Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
                    using (var reader = XmlReader.Create(response.GetResponseStream())) {
                        var target_controller = deserializer.DeserializeServiceController(reader);
                        ServiceDescriptionTests.AssertEquality(controller, target_controller);
                    }
                }
            }
        }
コード例 #2
0
        public void ActionNameTest()
        {
            var service    = new DummyService <ActionNameTestClass> ();
            var controller = new ServiceController(new[] { new DummyServiceAction("foo") }, null);

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #3
0
        public void UnimplementedOptionalStateVariable()
        {
            var service    = new DummyService <OptionalStateVariablesClass> ();
            var controller = new ServiceController(null,
                                                   new[] { new DummyStateVariable("BarChanged", "string") });

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #4
0
        public void UnimplementedOptionalAction()
        {
            var service    = new DummyService <OptionalActionClass> ();
            var controller = new ServiceController(
                new[] { new DummyServiceAction("Bar", new [] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) }) },
                new[] { new StateVariable("A_ARG_bar", "string") });

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #5
0
        public void StateVariableIsMulticastTest()
        {
            var service    = new DummyService <StateVariableIsMulticastTestClass> ();
            var controller = new ServiceController(null,
                                                   new[] {
                new DummyStateVariable("FooChanged", "string", true)
            }
                                                   );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #6
0
        public void EventedRelatedStateVariableTest()
        {
            var service    = new DummyService <EventedRelatedStateVariableTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("GetFoo", new[] { new Argument("foo", "Foo", ArgumentDirection.Out) })
            },
                new[] {
                new DummyStateVariable("Foo", "string")
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #7
0
        public void EnumArgumentNameTest()
        {
            var service    = new DummyService <EnumArgumentNameTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) })
            },
                new[] {
                new StateVariable("A_ARG_bar", new[] { "foo", "bar" })
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #8
0
        public void RelatedStateVariableAllowedValueRangeTest()
        {
            var service    = new DummyService <RelatedStateVariableAllowedValueRangeTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) })
            },
                new[] {
                new StateVariable("A_ARG_bar", "i4", new AllowedValueRange("0", "100", "2"))
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #9
0
        public void RelatedStateVariableDataTypeTest()
        {
            var service    = new DummyService <RelatedStateVariableDataTypeTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) })
            },
                new[] {
                new StateVariable("A_ARG_bar", "string.foo")
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #10
0
        public void ReturnArgumentRelatedStateVariableNameTest()
        {
            var service    = new DummyService <ReturnArgumentRelatedStateVariableNameTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("result", "X_ARG_foo", ArgumentDirection.Out, true) })
            },
                new[] {
                new StateVariable("X_ARG_foo", "string")
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #11
0
        public void RelatedStateVariableAllowedValuesConflictTest3()
        {
            var service    = new DummyService <RelatedStateVariableAllowedValuesConflictTest3Class> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) }),
                new DummyServiceAction("Bar", new[] { new Argument("bar", "A_ARG_Bar_bar", ArgumentDirection.In) })
            },
                new[] {
                new StateVariable("A_ARG_bar", new[] { "Foo", "Bar" }),
                new StateVariable("A_ARG_Bar_bar", new[] { "foo", "bar" })
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #12
0
        public void ArgumentTypeConflictTest()
        {
            var service    = new DummyService <ArgumentTypeConflictTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] { new Argument("bar", "A_ARG_bar", ArgumentDirection.In) }),
                new DummyServiceAction("Bar", new[] { new Argument("bar", "A_ARG_Bar_bar", ArgumentDirection.In) })
            },
                new[] {
                new StateVariable("A_ARG_bar", "string"),
                new StateVariable("A_ARG_Bar_bar", "i4")
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #13
0
        public void ArgumentsTest()
        {
            var service    = new DummyService <ArgumentsTestClass> ();
            var controller = new ServiceController(
                new[] {
                new DummyServiceAction("Foo", new[] {
                    new Argument("stringArg", "A_ARG_stringArg", ArgumentDirection.In),
                    new Argument("intArg", "A_ARG_intArg", ArgumentDirection.In),
                    new Argument("byteArg", "A_ARG_byteArg", ArgumentDirection.In),
                    new Argument("ushortArg", "A_ARG_ushortArg", ArgumentDirection.In),
                    new Argument("uintArg", "A_ARG_uintArg", ArgumentDirection.In),
                    new Argument("sbyteArg", "A_ARG_sbyteArg", ArgumentDirection.In),
                    new Argument("shortArg", "A_ARG_shortArg", ArgumentDirection.In),
                    new Argument("longArg", "A_ARG_longArg", ArgumentDirection.In),
                    new Argument("floatArg", "A_ARG_floatArg", ArgumentDirection.In),
                    new Argument("doubleArg", "A_ARG_doubleArg", ArgumentDirection.In),
                    new Argument("charArg", "A_ARG_charArg", ArgumentDirection.In),
                    new Argument("dateTimeArg", "A_ARG_dateTimeArg", ArgumentDirection.In),
                    new Argument("boolArg", "A_ARG_boolArg", ArgumentDirection.In),
                    new Argument("byteArrayArg", "A_ARG_byteArrayArg", ArgumentDirection.In),
                    new Argument("uriArg", "A_ARG_uriArg", ArgumentDirection.In)
                })
            },
                new[] {
                new StateVariable("A_ARG_stringArg", "string"),
                new StateVariable("A_ARG_intArg", "i4"),
                new StateVariable("A_ARG_byteArg", "ui1"),
                new StateVariable("A_ARG_ushortArg", "ui2"),
                new StateVariable("A_ARG_uintArg", "ui4"),
                new StateVariable("A_ARG_sbyteArg", "i1"),
                new StateVariable("A_ARG_shortArg", "i2"),
                new StateVariable("A_ARG_longArg", "int"),
                new StateVariable("A_ARG_floatArg", "r4"),
                new StateVariable("A_ARG_doubleArg", "r8"),
                new StateVariable("A_ARG_charArg", "char"),
                new StateVariable("A_ARG_dateTimeArg", "date"),
                new StateVariable("A_ARG_boolArg", "boolean"),
                new StateVariable("A_ARG_byteArrayArg", "bin"),
                new StateVariable("A_ARG_uriArg", "uri")
            }
                );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }
コード例 #14
0
        public void StateVariablesTest()
        {
            var service    = new DummyService <StateVariablesTestClass> ();
            var controller = new ServiceController(null,
                                                   new[] {
                new DummyStateVariable("StringChanged", "string"),
                new DummyStateVariable("IntChanged", "i4"),
                new DummyStateVariable("ByteChanged", "ui1"),
                new DummyStateVariable("UshortChanged", "ui2"),
                new DummyStateVariable("UintChanged", "ui4"),
                new DummyStateVariable("SbyteChanged", "i1"),
                new DummyStateVariable("ShortChanged", "i2"),
                new DummyStateVariable("LongChanged", "int"),
                new DummyStateVariable("FloatChanged", "r4"),
                new DummyStateVariable("DoubleChanged", "r8"),
                new DummyStateVariable("CharChanged", "char"),
                new DummyStateVariable("BoolChanged", "boolean"),
                new DummyStateVariable("ByteArrayChanged", "bin"),
                new DummyStateVariable("UriChanged", "uri")
            }
                                                   );

            ServiceDescriptionTests.AssertEquality(controller, service.GetController());
        }