Exemple #1
0
        public void GetContractMessageParameter()
        {
            ContractDescription cd = ContractDescription.GetContract(typeof(IMessageParameter));

            ServiceAssert.AssertContractDescription(
                "IMessageParameter", "http://tempuri.org/",
                SessionMode.Allowed, typeof(IMessageParameter), null,
                cd, "contract");

            OperationDescription od = cd.Operations [0];

            ServiceAssert.AssertOperationDescription(
                "ReturnMessage", null, null,
                typeof(IMessageParameter).GetMethod("ReturnMessage"),
                true, false, false,
                od, "operation");

            MessageDescription md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IMessageParameter/ReturnMessage",
                MessageDirection.Input,
                // Body.WrapperName is null
                null, null, null, false,
                md, "ReturnMessage");

            ServiceAssert.AssertMessagePartDescription(
                "arg", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(Message), md.Body.Parts [0], "ReturnMessage input");
        }
        public void Properties()
        {
            MessageEncoder t = new TextElement().CreateMessageEncoderFactory().Encoder;
            MessageEncoder b = new BinaryElement().CreateMessageEncoderFactory().Encoder;
            MessageEncoder m = new MtomElement().CreateMessageEncoderFactory().Encoder;

            // TextMessageEncodingBindingElement.WriteEncoding
            // default value is UTF8.
            ServiceAssert.AssertMessageEncoder(
                // Those curly double quotations are smelly, very implementation specific.
                "application/soap+xml; charset=utf-8", "application/soap+xml",
                MessageVersion.Default, t, "Text");
            ServiceAssert.AssertMessageEncoder(
                "application/soap+msbin1", "application/soap+msbin1",
                MessageVersion.Default, b, "Binary");
            ServiceAssert.AssertMessageEncoder(
                "multipart/related; type=\"application/xop+xml\"", "multipart/related",
                MessageVersion.Default, m, "Mtom");

            MessageEncoder t2 = new TextElement(
                MessageVersion.Soap11WSAddressing10,
                Encoding.UTF8)
                                .CreateMessageEncoderFactory().Encoder;

            ServiceAssert.AssertMessageEncoder(
                // Those curly double quotations are smelly, very implementation specific.
                "text/xml; charset=utf-8", "text/xml",
                MessageVersion.Soap11WSAddressing10, t2, "Text2");
        }
Exemple #3
0
        public void WindowsService_Cmds_InstallAndUninstall()
        {
            var output = Run("ServiceUninstall.cmd");

            output = Run("ServiceInstall.cmd");

            // Check if service was really installed.
            ServiceAssert.IsStopped("TaskManager");

            output = Run("ServiceStart.cmd", waitForExit: false);
            output = Run("ServiceStop.cmd", waitForExit: false);
            output = Run("ServiceUninstall.cmd");
        }
Exemple #4
0
        public void TestContractFromObject()
        {
            ContractDescription cd = ContractDescription.GetContract(typeof(Foo));

            ServiceAssert.AssertContractDescription(typeof(IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null, cd, "#1");
            Assert.AreEqual(cd.Operations.Count, 2);
            OperationBehaviorAttribute op = cd.Operations.Find("HeyHey").Behaviors.Find <OperationBehaviorAttribute> ();

            Assert.IsNotNull(op);
            Assert.AreEqual(
                op.ReleaseInstanceMode,
                ReleaseInstanceMode.None, "#2");

            cd = ContractDescription.GetContract(typeof(IFoo), typeof(Foo));
            ServiceAssert.AssertContractDescription(typeof(IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null, cd, "#3");
            Assert.AreEqual(cd.Operations.Count, 2, "#4");
            Assert.AreEqual(
                cd.Operations.Find("HeyHey").Behaviors.Find <OperationBehaviorAttribute> ().ReleaseInstanceMode,
                ReleaseInstanceMode.AfterCall, "#5");
        }
Exemple #5
0
        public void GetContractParamRenamed()
        {
            ContractDescription cd = ContractDescription.GetContract(typeof(IFooMsgParams));

            Assert.AreEqual(1, cd.Operations.Count, "Operation count");

            // Operation #1
            OperationDescription od = cd.Operations [0];

            ServiceAssert.AssertOperationDescription(
                "MyFoo", null, null,
                typeof(IFooMsgParams).GetMethod("Foo"),
                true, false, false,
                od, "MyFoo");

            // Operation #1 -> Message #1
            MessageDescription md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFooMsgParams/MyFoo",
                MessageDirection.Input,
                null, "MyFoo", "http://tempuri.org/", false,
                md, "MyFoo");

            ServiceAssert.AssertMessagePartDescription(
                "MyParam", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "MyFoo.msg");

            md = od.Messages [1];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFooMsgParams/MyFooResponse",
                MessageDirection.Output,
                null, "MyFooResponse",
                "http://tempuri.org/", true,
                md, "MyFoo");

            ServiceAssert.AssertMessagePartDescription(
                "MyResult", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.ReturnValue, "MyResult ReturnValue");
        }
Exemple #6
0
        public void InternalTestGetContract(ContractDescription cd)
        {
            ServiceAssert.AssertContractDescription(
                "IFoo", "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null,
                cd, "contract");

            Assert.AreEqual(2, cd.Operations.Count, "Operation count");

            // Operation #1
            OperationDescription od = cd.Operations [0];

            ServiceAssert.AssertOperationDescription(
                "HeyDude", null, null,
                typeof(IFoo).GetMethod("HeyDude"),
                true, false, false,
                od, "HeyDude");

            // Operation #1 -> Message #1
            MessageDescription md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyDude",
                MessageDirection.Input,
                null, "HeyDude", "http://tempuri.org/", false,
                md, "HeyDude");

            ServiceAssert.AssertMessagePartDescription(
                "msg", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyDude.msg");
            ServiceAssert.AssertMessagePartDescription(
                "msg2", "http://tempuri.org/", 1, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [1], "HeyDude.msg");

            // Operation #1 -> Message #2
            md = od.Messages [1];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyDudeResponse",
                MessageDirection.Output,
                null, "HeyDudeResponse",
                "http://tempuri.org/", true,
                md, "HeyDude");

            ServiceAssert.AssertMessagePartDescription(
                "HeyDudeResult", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.ReturnValue, "HeyDudeResponse ReturnValue");

            // Operation #2
            od = cd.Operations [1];

            ServiceAssert.AssertOperationDescription(
                "HeyHey", null, null,
                typeof(IFoo).GetMethod("HeyHey"),
                true, false, false,
                od, "HeyHey");

            // Operation #2 -> Message #1
            md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyHey",
                MessageDirection.Input,
                null, "HeyHey", "http://tempuri.org/", false,
                md, "HeyHey");

            ServiceAssert.AssertMessagePartDescription(
                "ref1", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyHey.ref1");

            // Operation #2 -> Message #2
            md = od.Messages [1];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyHeyResponse",
                MessageDirection.Output,
                null, "HeyHeyResponse",
                "http://tempuri.org/", true,
                md, "HeyHey");

            ServiceAssert.AssertMessagePartDescription(
                "HeyHeyResult", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(void), md.Body.ReturnValue, "HeyHeyResponse ReturnValue");

            ServiceAssert.AssertMessagePartDescription(
                "out1", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyHey.out1");
            ServiceAssert.AssertMessagePartDescription(
                "ref1", "http://tempuri.org/", 1, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [1], "HeyHey.ref1");
        }